Exemplo n.º 1
0
        // Builds object in unity
        public override void Build()
        {
            bullet1 = Object.Instantiate(bulletPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.5f), Quaternion.identity);
            bullet2 = Object.Instantiate(bulletPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.5f), Quaternion.identity);
            bullet3 = Object.Instantiate(bulletPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.5f), Quaternion.identity);
            bullet4 = Object.Instantiate(bulletPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.5f), Quaternion.identity);

            bullet1.GetComponent <TriggerObject>().OnCollisionWithBall.AddListener(maze.KillBall);
            bullet2.GetComponent <TriggerObject>().OnCollisionWithBall.AddListener(maze.KillBall);
            bullet3.GetComponent <TriggerObject>().OnCollisionWithBall.AddListener(maze.KillBall);
            bullet4.GetComponent <TriggerObject>().OnCollisionWithBall.AddListener(maze.KillBall);

            bullet1.GetComponent <TriggerObject>().CheckTag = "Wall";
            bullet2.GetComponent <TriggerObject>().CheckTag = "Wall";
            bullet3.GetComponent <TriggerObject>().CheckTag = "Wall";
            bullet4.GetComponent <TriggerObject>().CheckTag = "Wall";

            bullet1.GetComponent <TriggerObject>().OnCollisionWithTag.AddListener(KillBullet1);
            bullet2.GetComponent <TriggerObject>().OnCollisionWithTag.AddListener(KillBullet2);
            bullet3.GetComponent <TriggerObject>().OnCollisionWithTag.AddListener(KillBullet3);
            bullet4.GetComponent <TriggerObject>().OnCollisionWithTag.AddListener(KillBullet4);

            bullet1.GetComponent <Bullet>().MoveDirection = new Vector3(0.01f, 0, 0);
            bullet2.GetComponent <Bullet>().MoveDirection = new Vector3(0, 0, 0.01f);
            bullet3.GetComponent <Bullet>().MoveDirection = new Vector3(-0.01f, 0, 0);
            bullet4.GetComponent <Bullet>().MoveDirection = new Vector3(0, 0, -0.01f);

            timer = timerMax;
        }
Exemplo n.º 2
0
        public Vector2 getValidLocation(float radius)
        {
            int  posX;
            int  posY;
            bool objNearby;

            do
            {
                objNearby = false;
                posX      = UnityEngine.Random.Range(0, (int)(maze.Width));
                posY      = UnityEngine.Random.Range(0, (int)(maze.Height));
                if (uniqueObjects[posX, posY])
                {
                    continue;
                }
                Collider[] nearbyObjects = Physics.OverlapSphere(maze.CoordsToPosition(posX, posY, 0, 0, .5f), radius);
                foreach (Collider i in nearbyObjects)
                {
                    if (i.tag == "UniqueObject" || i.tag == "Player")
                    {
                        objNearby = true;
                        break;
                    }
                }
            } while (objNearby);
            return(new Vector2(posX, posY));
        }
Exemplo n.º 3
0
 public SpikeBall(int xCoord, int yCoord, GameObject spikeBallPrefab, GameObject warningPadPrefab, float timerMax, Maze maze) : base(xCoord, yCoord)
 {
     this.maze            = maze;
     active               = false;
     this.timerMax        = timerMax;
     this.spikeBallPrefab = spikeBallPrefab;
     warningPad           = Object.Instantiate(warningPadPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.1f), Quaternion.Euler(90, 0, 0));
     warningTimer         = 2;
 }
Exemplo n.º 4
0
 public Turret(int xCoord, int yCoord, GameObject turretPrefab, GameObject bulletPrefab, float timerMax, Maze maze) : base(xCoord, yCoord)
 {
     this.maze         = maze;
     active            = false;
     this.timerMax     = timerMax;
     this.turretPrefab = turretPrefab;
     this.bulletPrefab = bulletPrefab;
     turret            = Object.Instantiate(turretPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.5f), Quaternion.Euler(90, 0, 0));
     warningTimer      = 2;
 }
Exemplo n.º 5
0
 // Builds object in unity
 public override void Build()
 {
     spikeBall = Object.Instantiate(spikeBallPrefab, maze.CoordsToPosition(X, Y, 0.5f, 0.5f, 0.5f), Quaternion.identity);
     spikeBall.GetComponent <TriggerObject>().OnCollisionWithBall.AddListener(maze.KillBall);
     timer = timerMax;
 }