Skip to content

Commit

Permalink
feat: Animcontroller 개선 & Alien에게 Skill할당 (#19)
Browse files Browse the repository at this point in the history
* Stalker 클래스 추가

* Tag 변경

* Alien 베이스 코드 구현

* 카메라 렌더링을 위한 layer 변경 코드 추가

* 프리팹 수정

* 안쓰는 코드 제거

* Alien Scale 수정

* CreatureType별 카메라 위치 수정

* feat: Animcontroller 개선 & Alien에게 Skill할당
  • Loading branch information
scarleter99 authored Mar 23, 2024
1 parent 5fb105f commit bbb51d5
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 122 deletions.
12 changes: 6 additions & 6 deletions Client/Assets/Resources/Prefabs/Aliens/Stalker.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ GameObject:
- component: {fileID: 2656646541101528400}
- component: {fileID: 8848567419615919483}
- component: {fileID: 6976675480461094696}
- component: {fileID: 5652327032334742129}
- component: {fileID: 2516994780171337258}
- component: {fileID: 4476358356948161216}
- component: {fileID: 9205723220890699314}
m_Layer: 0
Expand Down Expand Up @@ -1150,7 +1150,7 @@ MonoBehaviour:
NetworkedBehaviours:
- {fileID: 8848567419615919483}
- {fileID: 6976675480461094696}
- {fileID: 5652327032334742129}
- {fileID: 2516994780171337258}
- {fileID: 4476358356948161216}
- {fileID: 9205723220890699314}
--- !u!114 &8848567419615919483
Expand All @@ -1166,11 +1166,11 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Animator: {fileID: 8694943018821805677}
TotalWords: 3
TotalWords: 0
ApplyTiming: 2
SyncSettings: 79
StateHashes: 00000000d60d65cf5b3f1ae1d6355d2351b741b83a14ae2622bf60df2bd9750c36deb24b9ce643ab657fb9ed1bb7b90b53d5474c0077695bdedc2838fcb625b6dd0602721fe5045ddfd244252afa8626a8b5caa3b8bdf7198b0ed22e3bc588839e816f3ce79b5e0ed4287b39d9d2b9c97c965e76d6fae0b873be0707fe1d2bbc107fe3c9aba58e3a69d74f9854e61c148a4d5d771636ac3c0b316b7b2c1396569ce229085c803cfbf9c4db4487810b6969e3c31cc19586d5db04bc3f8c16c1802952263f2a8f6f1bc14ce7e604898d4c27398eeaba3676e238793a6700677f7b822833fe20e23b685928a8cea68c4ffde5227cfe2210f8a511a3dd9230482cdaf23aed786d421c22c806fb9dfd9b008e13f9c8fb6bd5a32d398fdc04805553ef04768500
TriggerHashes: 000000003b2dc047
TriggerHashes: 00000000
--- !u!114 &6976675480461094696
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1206,7 +1206,7 @@ MonoBehaviour:
StepRequireGroundTarget: 0
SnapDistance: 0.25
SnapSpeed: 4
--- !u!114 &5652327032334742129
--- !u!114 &2516994780171337258
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -1215,7 +1215,7 @@ MonoBehaviour:
m_GameObject: {fileID: 8694943018831287373}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 22d7dd4b10554c359084716773cb6f10, type: 3}
m_Script: {fileID: 11500000, guid: 430d34e7eabc46ba86caccfe28e7476b, type: 3}
m_Name:
m_EditorClassIdentifier:
_DataId: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ protected override void PlayMove()
}
}

protected override void PlayInteract()
public void PlayUseSkill1()
{
SetTrigger("attack");
Debug.Log("Alien PlayInteract anim called");
}

protected override void PlayDead()
{
// TODO
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ public void UpdateAnimation()
case Define.CreatureState.Move:
PlayMove();
break;
case Define.CreatureState.Interact:
PlayInteract();
break;
case Define.CreatureState.Dead:
PlayDead();
break;
}
}

Expand All @@ -52,23 +46,10 @@ protected virtual void PlayMove()
{
}

protected virtual void PlayInteract()
{
}

protected virtual void PlayDead()
{
}

#endregion

#region SetParameter

protected void SetParameter()
{

}

protected void SetTrigger(string parameter)
{
NetworkAnim.SetTrigger("IsRunning");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

public class CrewAnimController : BaseAnimController
{
public float SitDown { get; protected set; }
public float SitSpeedParameter { get; protected set; }
[Networked] public float SitDown { get; protected set; }
[Networked] public float SitSpeedParameter { get; protected set; }

protected override void Init()
{
Expand Down Expand Up @@ -73,12 +73,17 @@ protected override void PlayMove()
}
}

protected override void PlayInteract()
public void PlayInteract()
{
// TODO
}

protected override void PlayDead()
public void PlayUseItem()
{
// TODO
}

public void PlayDead()
{
// TODO
}
Expand Down
9 changes: 4 additions & 5 deletions Client/Assets/Scripts/Contents/Item/BaseItem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Fusion;

public class BaseItem
public abstract class BaseItem
{
public Crew Owner { get; set; }

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public virtual void Rpc_Use()
{
public abstract bool CheckAndUseItem();

}
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
protected abstract void Rpc_Use();
}
8 changes: 7 additions & 1 deletion Client/Assets/Scripts/Contents/Item/Battery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

public class Battery : BaseItem
{
public override bool CheckAndUseItem()
{
Rpc_Use();
return true;
}

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public override void Rpc_Use()
protected override void Rpc_Use()
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public override void Spawned()

public void Interact(Creature creature)
{
creature.Inventory.Rpc_CheckAndGetItem(ItemType);
((Crew)creature).Inventory.CheckAndGetItem(ItemType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override IEnumerator ProgressWork()
while (WorkProgress < _requiredWorkAmount && !IsCompleted)
{

if (_workingCreature.Velocity.magnitude >= 1f)
if (_workingCreature.CreatureState != Define.CreatureState.Interact)
{
Interrupt();
}
Expand All @@ -37,7 +37,7 @@ protected override IEnumerator ProgressWork()
tempworkamount = WorkProgress;
}
/////////////////

yield return null;
}

Expand Down
9 changes: 4 additions & 5 deletions Client/Assets/Scripts/Contents/Skill/BaseSkill.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Fusion;

public class BaseSkill
public abstract class BaseSkill
{
public Alien Owner { get; set; }

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public virtual void Rpc_Use()
{
public abstract bool CheckAndUseSkill();

}
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public abstract void Rpc_UseSkill();
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using Fusion;
using System.Buffers;
using UnityEngine;

public class AlienSkill : BaseSkill
public class BasicAttack : BaseSkill
{
[SerializeField] private float attackRange = 2f; // 근접 공격 범위
private float attackRange = 2f; // 근접 공격 범위

[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public override bool CheckAndUseSkill()
{
Rpc_UseSkill();
return true;
}

public override void Rpc_Use()
[Rpc(RpcSources.StateAuthority, RpcTargets.All)]
public override void Rpc_UseSkill()
{
try
{
Expand Down
70 changes: 57 additions & 13 deletions Client/Assets/Scripts/Controllers/Alien.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System.Collections.Generic;
using UnityEngine;
using Data;

public class Alien : Creature
public abstract class Alien : Creature
{
#region Field

public AlienData AlienData => CreatureData as AlienData;
public AlienStat AlienStat => (AlienStat)BaseStat;

public List<BaseSkill> Skills { get; protected set; }

#endregion

public override void SetInfo(int templateID)
Expand All @@ -18,16 +21,59 @@ public override void SetInfo(int templateID)
base.SetInfo(templateID);

AlienStat.SetStat(AlienData);

Skills = new List<BaseSkill>();
}

protected override void HandleInput()
{
base.HandleInput();

if (Input.GetKeyDown(KeyCode.F))
{
if (CheckInteract(false))
{
CreatureState = Define.CreatureState.Interact;
return;
}
}
else
CheckInteract(true);

if (Input.GetMouseButtonDown(0))
{
UseSkill(1);
return;
if (CheckAndUseSkill(0))
{
CreatureState = Define.CreatureState.Use;
return;
}
}

if (Input.GetMouseButtonDown(1))
{
if (CheckAndUseSkill(1))
{
CreatureState = Define.CreatureState.Use;
return;
}
}

if (Input.GetKeyDown(KeyCode.Q))
{
if (CheckAndUseSkill(2))
{
CreatureState = Define.CreatureState.Use;
return;
}
}

if (Input.GetKeyDown(KeyCode.R))
{
if (CheckAndUseSkill(3))
{
CreatureState = Define.CreatureState.Use;
return;
}
}

if (Velocity == Vector3.zero)
Expand Down Expand Up @@ -110,16 +156,14 @@ protected override void UpdateDead()

#endregion

#region Interact

protected virtual bool UseSkill(int skillNum)
protected bool CheckAndUseSkill(int skillIdx)
{
return false;
}

#endregion

#region Event
if (Skills[skillIdx] == null)
{
Debug.Log("No SKill" + skillIdx);
return false;
}

#endregion
return Skills[skillIdx].CheckAndUseSkill();
}
}
Loading

0 comments on commit bbb51d5

Please sign in to comment.