本文整理汇总了C#中CharacterState类的典型用法代码示例。如果您正苦于以下问题:C# CharacterState类的具体用法?C# CharacterState怎么用?C# CharacterState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CharacterState类属于命名空间,在下文中一共展示了CharacterState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Aim
public void Aim()
{
if (snowBallInstanceScript != null) {
snowBallInstanceScript.Aim ();
}
state = CharacterState.IS_AIMING;
}
示例2: OnDeserialize
private CharacterState serverLastState; //SERVER: Store last state
#endregion Fields
#region Methods
/// <summary>
/// All Clients: Deserialize the state from network
/// </summary>
/// <param name="reader"></param>
/// <param name="initialState"></param>
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
CharacterState state = new CharacterState();
state.state = reader.ReadInt32();
state.position = reader.ReadVector3();
state.rotation = reader.ReadQuaternion();
//Client: Received a new state for the local player, treat it as an ACK and do reconciliation
if (isLocalPlayer) {
SendMessage("ServerState", state, SendMessageOptions.DontRequireReceiver);
} else {
//Other Clients: Received a state, treat it like a new position snapshot from authority
if (initialState)
{
//Others Clients: First state, just snap to new position
transform.position = state.position;
transform.rotation = state.rotation;
}
else if (networkInterpolation != null)
{
//Others Clients: Interpolate between received positions
networkInterpolation.ReceiveState(state);
}
}
}
示例3: AddState
public virtual void AddState(CharacterState state)
{
bool changed = (this._state & state) != state;
if (changed)
{
this._state |= state;
switch (state)
{
case CharacterState.OnGround:
this.RemoveState(CharacterState.OnJump);
break;
case CharacterState.OnJump:
this.RemoveState(CharacterState.OnGround);
this.RemoveState(CharacterState.OnWall);
break;
case CharacterState.Initialized:
case CharacterState.OnWall:
case CharacterState.Shooting:
case CharacterState.Damage:
default:
break;
}
this.OnStateChange(state, true);
}
}
示例4: SetCharacterStateUI
public void SetCharacterStateUI(CharacterState characterState){
switch(characterState){
case CharacterState.FULL:
spriteRenderer.sprite = _characterSprite[3];
emotionRenderer.sprite = _emotionSprite[3];
SetEmotionScaleRate(0.005f);
_hungerLevelBar.mainTexture = _hungerBar[(int)HungerBarState.HUNGER_BAR_100];
break;
case CharacterState.SATISFIED:
spriteRenderer.sprite = _characterSprite[2];
emotionRenderer.sprite = _emotionSprite[2];
SetEmotionScaleRate(0.006f);
_hungerLevelBar.mainTexture = _hungerBar[(int)HungerBarState.HUNGER_BAR_60];
break;
case CharacterState.HUNGRY:
spriteRenderer.sprite = _characterSprite[1];
emotionRenderer.sprite = _emotionSprite[1];
SetEmotionScaleRate(0.008f);
_hungerLevelBar.mainTexture = _hungerBar[(int)HungerBarState.HUNGER_BAR_30];
break;
case CharacterState.DYING:
spriteRenderer.sprite = _characterSprite[0];
emotionRenderer.sprite = _emotionSprite[0];
SetEmotionScaleRate(0.012f);
_hungerLevelBar.mainTexture = _hungerBar[(int)HungerBarState.HUNGER_BAR_0];
break;
default:
break;
}
}
示例5: Awake
// Use this for initialization
void Awake()
{
CS = CharacterState.Idle;
tr = GetComponent<Transform> ();
ani = GameObject.Find ("Character1").GetComponent<Animation> ();
GetComponent<Rigidbody> ().WakeUp ();
}
示例6: AddState
public void AddState(CharacterState state)
{
if (dictionary.ContainsKey(state.Name) || dictionary.ContainsValue(state))
return;
list.Add(state);
dictionary.Add(state.Name, state);
}
示例7: OnEnter
public override void OnEnter(CharacterState owner)
{
base.OnEnter(owner);
UnityEngine.Debug.Log("StateAttack.OnEnter");
}
示例8: Awake
void Awake()
{
coords = new int[2];
lastCoords = new int[2];
canSee = new List<Player> ();
m_AttackAxisInUse = false;
tr = transform;
CombatMode = false;
pos = transform.position;
currentPath = new List<Vector2> ();
controller = GetComponent<PlayerController>();
workingAI = new AIBase (this);
lastInput = Vector3.one;
playerStats = new PlayerStats ();
currentState = CharacterState.Still;
controller.SetSpeed (playerStats.GetSpeed());
isStuck = 0;
canAttack = "Enemy";
coolDownLimit = playerStats.GetAttackCooldown();
currentAttackCoolDown = 0;
inventory = GetComponent<InventoryBase>();
weaponController = GetComponentInChildren<WeaponController> ();
anim = GetComponent<Animator>();
spriteRen = GetComponent<SpriteRenderer> ();
//seeker = GetComponent<Seeker> ();
}
示例9: CharacterAnimationEvent
/// <summary>
/// Respond to an animation event.
/// </summary>
/// <param name='state'>
/// State.
/// </param>
/// <param name='previousState'>
/// Previous state.
/// </param>
public void CharacterAnimationEvent (CharacterState state, CharacterState previousState) {
currentState = state;
this.previousState = previousState;
transform.localPosition = rootOffset;
switch (state) {
case CharacterState.IDLE: Idle(previousState); break;
case CharacterState.WALKING: Walk(); break;
case CharacterState.RUNNING: Run(); break;
case CharacterState.SLIDING: Slide(); break;
case CharacterState.JUMPING: Jump(); break;
case CharacterState.AIRBORNE: Airborne(); break;
case CharacterState.FALLING: Fall(); break;
case CharacterState.DOUBLE_JUMPING: Jump(); break;
case CharacterState.WALL_JUMPING: Jump(); break;
case CharacterState.HOLDING: Hold(previousState); break;
case CharacterState.CLIMBING: Climb(); break;
case CharacterState.CLIMB_TOP_OF_LADDER_UP: ClimbTopUp(); break;
case CharacterState.CLIMB_TOP_OF_LADDER_DOWN: ClimbTopDown(); break;
case CharacterState.LEDGE_HANGING: LedgeHang(); break;
case CharacterState.LEDGE_CLIMBING: LedgeClimb(); break;
case CharacterState.LEDGE_CLIMB_FINISHED: Idle (previousState); break;
case CharacterState.ROPE_CLIMBING: RopeClimb(); break;
case CharacterState.ROPE_SWING: RopeSwing();break;
case CharacterState.ROPE_HANGING: RopeHang();break;
case CharacterState.WALL_SLIDING: WallSlide(); break;
case CharacterState.CROUCHING: Crouch(); break;
case CharacterState.CROUCH_SLIDING: CrouchSlide(); break;
case CharacterState.STUNNED: Stunned(previousState); break;
case CharacterState.PUSHING: Push(); break;
case CharacterState.PULLING: Pull(); break;
}
}
示例10: FollowAction
public FollowAction(GameObject actor, GameObject targetCharacter, float maximumDistance, float minimumDistance, Reason reason, bool canStartDialogueWithAgents)
: base(actor)
{
InitInteractionInfo(true, canStartDialogueWithAgents);
this.targetCharacter = targetCharacter;
this.targetCharacterState = (CharacterState)targetCharacter.GetComponent("CharacterState");
this.maximumDistance = maximumDistance;
this.minimumDistance = minimumDistance;
this.reason = reason;
switch(reason) {
case Reason.SEX:
targetCharacterState.SetTask(CharacterState.Task.SEX, actor);
TaskHelp.ShowHelp(TaskHelp.SEX, actor);
break;
case Reason.DANCE:
targetCharacterState.SetTask(CharacterState.Task.DANCE, actor);
TaskHelp.ShowHelp(TaskHelp.DANCE, null);
break;
case Reason.POKER_WITHOUT_MONEY:
targetCharacterState.SetTask(CharacterState.Task.POKER, actor);
TaskHelp.ShowHelp(TaskHelp.POKER, null);
break;
case Reason.POKER_WITH_MONEY:
targetCharacterState.SetTask(CharacterState.Task.POKER, actor);
TaskHelp.ShowHelp(TaskHelp.POKER, null);
break;
case Reason.DRINK:
targetCharacterState.SetTask(CharacterState.Task.DRINK, actor);
TaskHelp.ShowHelp(TaskHelp.DRINK, actor);
break;
}
ending = false;
}
示例11: Awake
// Camera myCam = GameObject.Find("_cameraMain");
// Use this for initialization
void Awake()
{
animation = GetComponent<Animation> ();
contr = GetComponent<PlayerController>();
_state = CharacterState.Idle;
// myCamera = GameObject.Find ("_cameraMain").camera;
}
示例12: SendToAllClient_MonsterState
public static void SendToAllClient_MonsterState(CharacterState character, State state)
{
Packet.GCAckMonsterState packet = new Packet.GCAckMonsterState();
packet.uniqueID = ((MonsterCharacter)character).UniqueID;
packet.typeID = 1;//
packet.state = state.ID;
packet.posX = character.transform.position.X.ToString();
packet.posY = character.transform.position.Y.ToString();
packet.posZ = character.transform.position.Z.ToString();
packet.dirX = character.transform.forward.X.ToString();
packet.dirY = character.transform.forward.Y.ToString();
packet.dirZ = character.transform.forward.Z.ToString();
string jsonPacket = JsonMapper.ToJson(packet);
try
{
lock (GameServer.Program.ms_ClientList)
{
foreach (GameServer.UserObject obj in GameServer.Program.ms_ClientList)
{
obj.Send(jsonPacket);
}
}
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
示例13: OnUpdate
public override void OnUpdate(CharacterState owner)
{
#if UNITY_EDITOR || UNITY_STANDALONE
owner.transform.position += owner.transform.forward * Time.deltaTime * speed;
#else //Server AI Logic
accumTime += Time.deltaTime;
if (accumTime > updateAccumTime)
{
if (owner.GetType() == typeof(MonsterCharacter))
{
MonsterCharacter monster = (MonsterCharacter)owner;
monster.SetStateIdle();
}
//Console.WriteLine("AIStateWalk.OnUpdate");
accumTime = 0.0f;
}
else
{
//owner.PosZ += speed * Time.deltaTime;
//Vector3.Forward of XnaGeometry is -Z
//so you should multiply -1 for serverside code
owner.transform.position += owner.transform.forward * Time.deltaTime * speed;
}
#endif
}
示例14: SetSpeed
public void SetSpeed(float speed)
{
this.speed = speed;
if(!crouch)
{
if(speed > minimumRunSpeed) {
//SendMessage("SetWalk", false, SendMessageOptions.DontRequireReceiver);
_characterState = CharacterState.Running;
} else if(speed > minimumWalkSpeed) {
//SendMessage("SetWalk", true, SendMessageOptions.DontRequireReceiver);
_characterState = CharacterState.Walking;
} else {
//SendMessage("SetIdle", true, SendMessageOptions.DontRequireReceiver);
_characterState = CharacterState.Idle;
}
} else {
if(speed > minimumRunSpeed) {
//SendMessage("SetCrouch", true, SendMessageOptions.DontRequireReceiver);
//SendMessage("SetWalk", false, SendMessageOptions.DontRequireReceiver);
_characterState = CharacterState.Walking_crouch;
} else if(speed > minimumWalkSpeed) {
//SendMessage("SetCrouch", true, SendMessageOptions.DontRequireReceiver);
//SendMessage("SetWalk", true, SendMessageOptions.DontRequireReceiver);
_characterState = CharacterState.Walking_crouch;
} else {
//SendMessage("SetCrouch", true, SendMessageOptions.DontRequireReceiver);
//SendMessage("SetIdle", true, SendMessageOptions.DontRequireReceiver);
_characterState = CharacterState.Idle_crouch;
}
}
}
示例15: CharacterActionSet
public CharacterActionSet(string n, CharacterState s, CharacterActionSetChangeFactor f, object o)
{
animname = n;
state = s;
switch (f)
{
case CharacterActionSetChangeFactor.AnimationCompleted:
break;
case CharacterActionSetChangeFactor.ArriveTarget:
target = (Vector2)o;
break;
case CharacterActionSetChangeFactor.Time:
duration = (double)o;
break;
case CharacterActionSetChangeFactor.ArriveAttackTarget:
interactive = (Character)o;
break;
case CharacterActionSetChangeFactor.ArriveInteractiveTarget:
interactive = (Character)o;
break;
case CharacterActionSetChangeFactor.EffectCompleted:
effectname = (string)o;
break;
}
factor = f;
}