本文整理汇总了C#中Visual.StopAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.StopAnimation方法的具体用法?C# Visual.StopAnimation怎么用?C# Visual.StopAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visual
的用法示例。
在下文中一共展示了Visual.StopAnimation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
void Awake () {
visual = transform.Find ("Visual").GetComponent <Visual> ();
transitable.Add (CharacterState.Spawn, new List<CharacterState> { CharacterState.Idle });
transitable.Add (CharacterState.Idle, new List<CharacterState> { CharacterState.Attack, CharacterState.Dead, CharacterState.Move, CharacterState.Stuck });
transitable.Add (CharacterState.Attack, new List<CharacterState> { CharacterState.Attack, CharacterState.Dead, CharacterState.Idle, CharacterState.Stuck });
transitable.Add (CharacterState.Move, new List<CharacterState> { CharacterState.Attack, CharacterState.Dead, CharacterState.Idle, CharacterState.Move, CharacterState.Stuck });
transitable.Add (CharacterState.Stuck, new List<CharacterState> { CharacterState.Attack, CharacterState.Dead, CharacterState.Idle, CharacterState.Move });
transitable.Add (CharacterState.Dead, new List<CharacterState> { });
controllable = true;
stateMachine.Add (CharacterState.Idle, () => {
CheckBlock ();
});
stateMachine.Add (CharacterState.Move, () => {
transform.position += dir * moveSpeed * Time.deltaTime;
CheckBlock ();
});
stateEnd.Add (CharacterState.Move, () => {
dir = Vector3.zero;
});
stateStart.Add (CharacterState.Attack, () => {
blurController.SetBlurs (true);
weapon.enabled = true;
trailController.gameObject.SetActive (true);
});
stateMachine.Add (CharacterState.Attack, () => {
float t = (Time.time - attackStartTime) / attackDuration;
t = Mathf.Clamp01 (t);
if (t >= 1f) {
transform.position = attackEndPoint;
RequestChangeState (CharacterState.Idle);
return;
}
t *= 2f;
var diff = attackEndPoint - attackStartPoint;
if (t < 1) {
transform.position = diff * 0.5f * t * t + attackStartPoint;
} else {
t--;
transform.position = -diff * 0.5f * (t * (t - 2f) - 1f) + attackStartPoint;
}
CheckBlock ();
});
stateEnd.Add (CharacterState.Attack, () => {
blurController.SetBlurs (false);
visual.StopAnimation ();
dir = Vector3.zero;
attackStartPoint = Vector3.zero;
attackEndPoint = Vector3.zero;
weapon.enabled = false;
trailController.gameObject.SetActive (false);
});
stateStart.Add (CharacterState.Dead, () => {
controllable = false;
});
}
示例2: Awake
void Awake () {
visual = transform.Find ("Visual").GetComponent <Visual> ();
transitable.Add (AiState.Spawn, new List<AiState> { AiState.Idle });
transitable.Add (AiState.Idle, new List<AiState> { AiState.Alarmed, AiState.Roaming });
transitable.Add (AiState.Roaming, new List<AiState> { AiState.Idle, AiState.Alarmed, AiState.Stuck });
transitable.Add (AiState.Alarmed, new List<AiState> { AiState.Attack, AiState.Stuck });
transitable.Add (AiState.Attack, new List<AiState> { AiState.Cooldown, AiState.Idle, AiState.Stuck });
transitable.Add (AiState.Cooldown, new List<AiState> { AiState.Idle });
transitable.Add (AiState.Stuck, new List<AiState> { AiState.Idle });
stateStart.Add (AiState.Idle, () => {
roamingStartTime = Time.time + 1f;
exclamationMark.SetActive (false);
});
stateMachine.Add (AiState.Idle, () => {
if (Time.time > roamingStartTime) {
RequestChangeState (AiState.Roaming, () => {
roamingDir = TrackPad.RandomDirection;
roamingStartPoint = transform.position;
});
}
CheckBlock ();
CheckPlayerInSight ();
});
stateStart.Add (AiState.Alarmed, () => {
exclamationMark.SetActive (true);
attackStartTime = Time.time + attackWaitTime;
});
stateMachine.Add (AiState.Alarmed, () => {
if (Time.time > attackStartTime) {
RequestChangeState (AiState.Attack, () => {
if (GameManager.GetInstance.player != null) {
attackStartPoint = transform.position;
dir = (GameManager.GetInstance.player.transform.position - attackStartPoint).normalized;
attackEndPoint = attackStartPoint + dir * attackRange;
var e = CreateTrackPadEventByDirection (TrackPad.FindNesrestDirection (dir));
visual.ForcePlayAnimation (e);
} else {
RequestChangeState (AiState.Cooldown);
}
});
} else {
if (GameManager.GetInstance.player != null) {
dir = (GameManager.GetInstance.player.transform.position - transform.position).normalized;
var e = CreateTrackPadEventByDirection (TrackPad.FindNesrestDirection (dir));
visual.ForcePlayAnimation (e);
}
}
});
stateStart.Add (AiState.Attack, () => {
weapon.enabled = true;
});
stateMachine.Add (AiState.Attack, () => {
float t = (Time.time - attackStartTime) / attackDuration;
t = Mathf.Clamp01 (t);
if (t >= 1f) {
transform.position = attackEndPoint;
RequestChangeState (AiState.Idle);
return;
}
t *= 2f;
var diff = attackEndPoint - attackStartPoint;
if (t < 1) {
transform.position = diff * 0.5f * t * t + attackStartPoint;
} else {
t--;
transform.position = -diff * 0.5f * (t * (t - 2f) - 1f) + attackStartPoint;
}
CheckBlock ();
});
stateEnd.Add (AiState.Attack, () => {
visual.StopAnimation ();
weapon.enabled = false;
RequestChangeState (AiState.Cooldown);
});
stateStart.Add (AiState.Cooldown, () => {
cooldownStartTime = Time.time;
});
stateMachine.Add (AiState.Cooldown, () => {
if (cooldownStartTime + attackCooldown > Time.time) {
RequestChangeState (AiState.Idle);
}
});
stateStart.Add (AiState.Roaming, () => {
var dir = new Vector3 (roamingDir.x, roamingDir.y, 0f);
roamingEndPoint = roamingStartPoint + roamingDistance * dir;
var e = CreateTrackPadEventByDirection (roamingDir);
visual.ForcePlayAnimation (e);
});
stateMachine.Add (AiState.Roaming, () => {
float t = (Time.time - roamingStartTime) / roamingDuration;
t = Mathf.Clamp01 (t);
transform.position = Vector3.Lerp (roamingStartPoint, roamingEndPoint, t);
if (t >= 1f) {
transform.position = roamingEndPoint;
//.........这里部分代码省略.........