Ejemplo n.º 1
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Salamander")
     {
         PlayerParent salamander = GetComponent <PlayerParent>();
         if (salamander.P2HealthBar.value <= 0)
         {
             reviving = true;
         }
     }
 }
Ejemplo n.º 2
0
 private void OnTriggerExit2D(Collider2D col)
 {
     if (col.gameObject.tag == "Eagle")
     {
         PlayerParent eagle = GetComponent <PlayerParent>();
         if (eagle.P1HealthBar.value <= 0)
         {
             reviveTime = 0;
             reviving   = false;
         }
     }
 }
Ejemplo n.º 3
0
 private void OnTriggerExit2D(Collider2D col)
 {
     if (col.gameObject.tag == "Salamander")
     {
         PlayerParent salamander = GetComponent <PlayerParent>();
         if (salamander.P2HealthBar.value <= 0)
         {
             reviveTime = 0;
             reviving   = false;
         }
     }
 }
Ejemplo n.º 4
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.tag == "Eagle")
     {
         print("eagle");
         PlayerParent eagle = GetComponent <PlayerParent>();
         if (eagle.P1HealthBar.value <= 0)
         {
             print("revive");
             reviving = true;
         }
     }
 }
Ejemplo n.º 5
0
 void OnTriggerStay2D(Collider2D col)
 {
     if (col.gameObject.tag == "Salamander")
     {
         PlayerParent salamander = GetComponent <PlayerParent>();
         if (salamander.P2HealthBar.value <= 0)
         {
             if (reviving)
             {
                 reviveTime += Time.deltaTime;
                 if (isPlayer1)
                 {
                     SalamanderReviveBG.gameObject.SetActive(true);
                     SalamanderReviveFill.gameObject.SetActive(true);
                     SalamanderReviveFill.fillAmount = (reviveTime / 1.5f);
                     if (reviveTime >= 1.5f)
                     {
                         reviveTime = 0;
                         source.PlayOneShot(revive);
                         reviving = false;
                         ReviveOther();
                     }
                 }
                 else
                 {
                     EagleReviveBG.gameObject.SetActive(true);
                     EagleReviveFill.gameObject.SetActive(true);
                     EagleReviveFill.fillAmount = (reviveTime / 1.5f);
                     if (reviveTime >= 1.5f)
                     {
                         source.PlayOneShot(revive);
                         reviveTime = 0;
                         reviving   = false;
                         ReviveOther();
                     }
                 }
             }
         }
     }
 }
    // a function that returns true if a player could move to the
    // position passed to this without being inside of another
    // player! row and column offset should always be equal to
    // 1,0, or 1   !!!!!!
    public bool IsThereAPlayerInThisSpot(PlayerParent x, int rowOffset, int columnOffset)
    {
        Position pos = new Position(x.myPosition.row + rowOffset, x.myPosition.column + columnOffset);
        int width = ((x.myWidth - 1) / 2);
        int length = ((x.myLength - 1) / 2);

        PlayerParent[] temp = GetAllOtherPlayers(x);
        for(int i = 0; i < temp.Length; i++)
        {
            Position pos1 = temp[i].myPosition;
            int nWidth = ((temp[i].myWidth - 1) / 2);
            int nLength = ((temp[i].myLength - 1) / 2);

            // check if a player is inside of pos, if so return false
            if ((pos.column >= pos1.column && pos.column - width <= pos1.column + nWidth) || (pos.column + width >= pos1.column - nWidth))
            {
                // the players horizontally are touching, so we also have to check rows to see if they are actually in the same place
                if ((pos.row >= pos1.row && pos.row - width <= pos1.row + nWidth)|| pos.row + width >= pos1.row - nWidth)
                {
                    return false;
                }
            }
        }
        return true;
    }
 // a function that returns an array of all the players, except for the
 // player passed to it as a paramater
 public PlayerParent[] GetAllOtherPlayers(PlayerParent y)
 {
     PlayerParent[] temp = new PlayerParent[21];
     for(int i = 0; i < allPlayersOnField.Length; i++)
     {
         if(allPlayersOnField[i] != y)
         {
             temp[i] = allPlayersOnField[i];
         }
     }
     return temp;
 }