Ejemplo n.º 1
0
 void OnEnable()
 {
     InteractWithGameObject.RegisterListener(OnInteracting);
     PlayerAttackEvent.RegisterListener(OnUnitAttacked);
     LeftMouseSelectEvent.RegisterListener(OnLeftMouseSelected);
     RightMouseSelectEvent.RegisterListener(OnRightClick);
 }
Ejemplo n.º 2
0
    /* private void HandleAttack()
     * {
     *   while(attackedObject != null)
     *   {
     *       if (rdyToAttack && attack)
     *       {
     *           //Debug.Log("Time since last attack: " + (Time.time - timeSinceAttack));
     *           if (Time.time - timeSinceAttack > stats.AttackCooldown)
     *           {
     *               timeSinceAttack = Time.time;
     *               Vector3 lookAtVec = new Vector3(attackedObject.transform.position.x, transform.position.y, attackedObject.transform.position.z);
     *               transform.LookAt(lookAtVec);
     *
     *               if (animatorController != null)
     *                   animatorController.Attack();
     *
     *               if (attackedObject != null)
     *               {
     *                   //AttackEvent(hit.transform.gameObject, damage);
     *                   PlayerAttackEvent unitAttackEvent = new PlayerAttackEvent();
     *                   unitAttackEvent.Description = "Unit " + gameObject.name + " has attacked.";
     *                   unitAttackEvent.UnitAttacked = attackedObject;
     *                   unitAttackEvent.UnitAttacker = gameObject;
     *                   unitAttackEvent.UnitStats = stats;
     *                   unitAttackEvent.FireEvent();
     *
     *               }
     *           }
     *       }
     *   }
     * }*/



    void OnEnable()
    {
        UnitDeathEvent.RegisterListener(OnEnemyUnitDeath);
        EnemyAttackEvent.RegisterListener(OnEnemyUnitAttack);
        LeftMouseSelectEvent.RegisterListener(OnLeftMouseSelected);
        RightMouseSelectEvent.RegisterListener(OnRightMouseClick);
        PlayerAttackEvent.RegisterListener(OnAttacked);
    }