Exemplo n.º 1
0
 private void OnDestroy()
 {
     if (Instance == this)
     {
         Instance = null;
     }
 }
Exemplo n.º 2
0
 private void Awake()
 {
     if (!Instance)
     {
         Instance = this;
     }
 }
Exemplo n.º 3
0
    public int numSpacesBack = 3; //Number of spaces to move the player back

    // Start is called before the first frame update
    void Start()
    {
        snake         = GameObject.FindGameObjectWithTag("Snake");
        player1Script = GameObject.Find("player");
        firstPlayer   = player1Script.GetComponent <player>();

        player2Script = GameObject.Find("player2");
        secondPlayer  = player2Script.GetComponent <player2>();
    }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        player1Script = GameObject.Find("player");
        firstPlayer   = player1Script.GetComponent <player>();

        player2Script = GameObject.Find("player2");
        secondPlayer  = player2Script.GetComponent <player2>();

        anim = GetComponent <Animation>();
    }
Exemplo n.º 5
0
 void Start()
 {
     myTransform   = GetComponent <Transform>();
     currentHealth = maxHealth;
     main          = this;
 }
 void Update()
 {
     RaycastHit2D[,] groupRaycast = new RaycastHit2D[4, 3] {
         { up, up1, up2 }, { down, down1, down2 }, { left, left1, left2 }, { right, right1, right2 }
     };
     for (int i = 0; i < 4; ++i)
     {
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "zombie" && canHitzombie)
             {
                 groupRaycast[i, j].transform.GetComponent <zombie>().zombieDie();
                 canHitzombie = false;
                 break;
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "Player")
             {
                 player p = groupRaycast[i, j].transform.GetComponent <player>();
                 if (p != null && canhitPlayer)
                 {
                     groupRaycast[i, j].transform.GetComponent <player>().playerisHitted();
                     canhitPlayer = false;
                     break;
                 }
                 player1 p1 = groupRaycast[i, j].transform.GetComponent <player1>();
                 if (p1 != null && canhitPlayer1)
                 {
                     groupRaycast[i, j].transform.GetComponent <player1>().playerisHitted();
                     canhitPlayer1 = false;
                     break;
                 }
                 player2 p2 = groupRaycast[i, j].transform.GetComponent <player2>();
                 if (p2 != null && canhitPlayer2)
                 {
                     groupRaycast[i, j].transform.GetComponent <player2>().playerisHitted();
                     canhitPlayer2 = false;
                     break;
                 }
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "boss" && canHitboss)
             {
                 groupRaycast[i, j].transform.GetComponent <BossController>().bosshitBoom();
                 canHitboss = false;
                 break;
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "Rao" && canHitrao)
             {
                 if (groupRaycast[i, j].collider.GetComponent <Bum>().includeItems == true)
                 {
                     GameController gcl = controller.GetComponent <GameController>();
                     Bum            b   = groupRaycast[i, j].collider.GetComponent <Bum>();
                     gcl.createItem   = true;
                     gcl.boomsize     = b.boomsize;
                     gcl.multiboom    = b.multiboom;
                     gcl.shoes        = b.shoes;
                     gcl.itemPosition = groupRaycast[i, j].transform.position;
                 }
                 Destroy(groupRaycast[i, j].collider);
                 canHitrao = false;
                 break;
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "coverItems" && canhitCoveritems)
             {
                 if (groupRaycast[i, j].collider.GetComponent <BumforcoverItems>().includeItems == true)
                 {
                     GameController   gcl = controller.GetComponent <GameController>();
                     BumforcoverItems b   = groupRaycast[i, j].collider.GetComponent <BumforcoverItems>();
                     gcl.createItem   = true;
                     gcl.boomsize     = b.boomsize;
                     gcl.multiboom    = b.multiboom;
                     gcl.shoes        = b.shoes;
                     gcl.itemPosition = groupRaycast[i, j].transform.position;
                 }
                 Destroy(groupRaycast[i, j].collider);
                 canhitCoveritems = false;
                 break;
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "shoes" && canhitShoes)
             {
                 groupRaycast[i, j].transform.GetComponent <Animator>().enabled = true;
                 Destroy(groupRaycast[i, j].transform.gameObject, 1f);
                 canhitShoes = false;
                 break;
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "boomsize" && canHitboomsize)
             {
                 groupRaycast[i, j].transform.GetComponent <Animator>().enabled = true;
                 Destroy(groupRaycast[i, j].transform.gameObject, 1f);
                 canHitboomsize = false;
                 break;
             }
         }
         for (int j = 0; j < 3; ++j)
         {
             if (groupRaycast[i, j].collider != null && groupRaycast[i, j].transform.tag == "multiboom" && canHitmultiboom)
             {
                 groupRaycast[i, j].transform.GetComponent <Animator>().enabled = true;
                 Destroy(groupRaycast[i, j].transform.gameObject, 1f);
                 canHitmultiboom = false;
                 break;
             }
         }
     }
 }