コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "player")
        {
            if (im.pickUpEnergy())
            {
                Movement mv = other.GetComponent <Movement>();

                ps.removeEnergy(mv.xPos, mv.zPos);
                ps.incPack(1);
                gameObject.SetActive(false);
            }
            else
            {
                Debug.Log("Inventory is full");
            }
        }
        else if (other.tag == "enemy3")

        {
            EnemyMovement3 mv = other.GetComponent <EnemyMovement3>();
            ps.removeEnergy(mv.xPos, mv.zPos);
            mv.charged = true;
            Renderer r = other.GetComponent <Renderer>();
            r.material.color = Color.yellow;
            gameObject.SetActive(false);
        }
    }
コード例 #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "enemy")
     {
         gameObject.SetActive(false);
         pa.removeEnemy(other.gameObject);
         other.gameObject.SetActive(false);
     }
     if (other.tag == "enemy3")
     {
         EnemyMovement3 mv = other.GetComponent <EnemyMovement3>();
         if (mv.charged)
         {
             ps.spawnEnergy(mv.xPos, mv.zPos, other.transform.position + new Vector3(0, 0.25f, 0));
         }
         gameObject.SetActive(false);
         pa.removeEnemy(other.gameObject);
         other.gameObject.SetActive(false);
     }
 }
コード例 #3
0
    private void spawnEnemy3()
    {
        int xPos = sg.getSpawnX();
        int zPos = 25;

        GameObject instance = (GameObject)Instantiate(enemy3, sg.tiles[xPos, zPos].transform.position + new Vector3(0, 0.75f, 0), transform.rotation);

        pa.addEnemy(instance);

        EnemyMovement3 em = instance.GetComponent <EnemyMovement3>();

        em.xPos = xPos;
        em.zPos = zPos;
        if (xPos == 1)
        {
            em.direction = 1;
        }
        else
        {
            em.direction = 3;
        }
    }