コード例 #1
0
 void Start()
 {
     Player = FindObjectOfType <Player>();
     gameStateController    = FindObjectOfType <GameStateController>();
     navMeshAgent           = GetComponent <NavMeshAgent>();
     capsuleCollider        = GetComponent <CapsuleCollider>();
     animator               = GetComponentInChildren <Animator>();
     movementAnimator       = GetComponentInChildren <MovementAnimator>();
     particleSystem         = GetComponentInChildren <ParticleSystem>();
     diedEventHandler       = GetComponentInChildren <DiedEventHandler>();
     diedEventHandler.Died += DestroyGameObject;
 }
コード例 #2
0
ファイル: Hurtable.cs プロジェクト: Seppli11/GPPCC12-Game
 /// <summary>
 /// This function is called, if this hurtable was hit by a weapon
 /// </summary>
 /// <param name="damage"></param>
 /// <param name="weapon"></param>
 /// <param name="from"></param>
 public void Damaged(int damage, GameObject from, Weapon weapon)
 {
     if (!isServer)
     {
         return;
     }
     this.life -= damage;
     CmdSetLife(life);
     if (this.life <= 0)
     {
         this.life = 0;
         if (DiedEventHandler != null)
         {
             DiedEventHandler.Invoke(this.gameObject, from, weapon);
         }
     }
     if (HittedEventHandler != null)
     {
         HittedEventHandler.Invoke(damage, from, weapon);
     }
 }