public void SetCurrentPlayers(GameObject player1, GameObject player2)
        {
            fighter1 = player1.GetComponent <SideScrollerFighter>();
            fighter2 = player2.GetComponent <SideScrollerFighter>();

            if (fighter1 == null || fighter2 == null)
            {
                Debug.Log("ERROR - NO FIGHTER SCRIPT");
            }
        }
        public void SetCurrentPlayers(SideScrollerFighter script, int id)
        {
            if (id == 1)
            {
                fighter1 = script;
            }
            if (id == 2)
            {
                fighter2 = script;
            }

            if (fighter1 == null || fighter2 == null)
            {
                Debug.Log("ERROR - NO FIGHTER SCRIPT");
            }
        }
示例#3
0
        public void TakeDamage(float damage)
        {
            // Death Transition
            if (currentHealth - damage <= 0)
            {
                Die();
            }

            // Damage Transition (If not Damaged or Dead)
            else
            {
                SideScrollerFighter scrollerFighter = this.GetComponent <SideScrollerFighter>();

                FighterState state = scrollerFighter.currentState;

                // Do Damage if is dead or Damaged
                if ((state == FighterState.Dead || state == FighterState.Dying || state == FighterState.Damaged))
                {
                    return;
                }

                // Process Damage
                currentHealth -= damage;
                scrollerFighter.Damaged();

                // Display Damage // Update UI
                if (playerBar != null)
                {
                    playerBar.SetHealth((int)currentHealth);
                }

                // Debug PRINTS
                //print(this.name + " took damage");
                //print(currentHealth);
            }
        }
 // Start is called before the first frame update
 protected virtual void Start()
 {
     // Auto Get
     moverScript   = GetComponent <SideScrollerMover>();
     fighterScript = GetComponent <SideScrollerFighter>();
 }