本文整理汇总了C#中Visual.ForcePlayAnimation方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.ForcePlayAnimation方法的具体用法?C# Visual.ForcePlayAnimation怎么用?C# Visual.ForcePlayAnimation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visual
的用法示例。
在下文中一共展示了Visual.ForcePlayAnimation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
//.........这里部分代码省略.........