Example #1
0
    public int EnemyShot(int x, int y)
    {
        x = Mathf.Abs(x);
        y = Mathf.Abs(y);
        Jobster jb  = GameObject.Find("jobster").GetComponent <Jobster>();
        Morpher mph = GameObject.Find("Morpher").GetComponent <Morpher>();

        Debug.Log("Enemy shot int, int");
        if (!jb.startedGame.Human.currentField.cells[x, y].IsShot)
        {
            jb.startedGame.Human.currentField.cells[x, y].IsShot = true;
            if (jb.startedGame.Human.currentField.cells[x, y].HasShip)
            {
                jb.startedGame.WhosTurn = 2;
                for (int i = 0; i < jb.startedGame.Human.ships.Length; i++)
                {
                    for (int j = 0; j < jb.startedGame.Human.ships[i].Size; j++)
                    {
                        Cell c = jb.startedGame.Human.ships[i].GetCell(j);
                        if (x == c.X && y == c.Y)
                        {
                            jb.startedGame.Human.ships[i].ShotIncrease();
                            mph.InstShotCell(x, y, 1, 's');
                            jb.PlayExplosion();
                            return(0);
                        }
                    }
                }
            }
            else
            {
                //jb.startedGame.WhosTurn = 1;
                mph.InstShotCell(x, y, 1, 'm');
                jb.PlayMiss();
                this.turnInProcess = false;

                /*if (this.currentCycle >= 3)
                 * {
                 *  this.justHit = false;
                 * }*/
                return(1);
            }
        }
        else
        {
            //jb.startedGame.WhosTurn = 2;

            /*if (this.currentCycle >= 3)
             * {
             *  this.justHit = false;
             * }*/
            this.turnInProcess = false;
            return(2);
        }

        return(3);
    }
Example #2
0
    public override void ShootTheBitch(int x, int y)
    {
        Jobster jb  = GameObject.Find("jobster").GetComponent <Jobster>();
        Morpher mph = GameObject.Find("Morpher").GetComponent <Morpher>();

        if (!jb.startedGame.AI.currentField.cells[x, y].IsShot)
        {
            jb.startedGame.AI.currentField.cells[x, y].IsShot = true;
            if (jb.startedGame.AI.currentField.cells[x, y].HasShip)
            {
                jb.startedGame.WhosTurn = 1;
                for (int i = 0; i < 10; i++)
                {
                    for (int j = 0; j < jb.startedGame.AI.ships[i].Size; j++)
                    {
                        Cell c = jb.startedGame.AI.ships[i].GetCell(j);
                        if (x == c.X && y == c.Y)
                        {
                            jb.startedGame.AI.ships[i].ShotIncrease();
                            mph.InstShotCell(x, y, 2, 's');
                            jb.PlayExplosion();
                        }
                    }
                }
            }
            else
            {
                jb.startedGame.WhosTurn = 2;
                mph.InstShotCell(x, y, 2, 'm');
                jb.PlayMiss();
            }
        }
        else
        {
            jb.startedGame.WhosTurn = 1;
        }
    }
Example #3
0
    public override int EnemyShot()
    {
        /*if (this.justHit)
         * {
         *  Debug.Log("Shooting after hit");
         *  this.ShootAfterHit();
         *  this.turnInProcess = false;
         *  return;
         * }
         *
         * if (this.jbRef.startedGame.WhosTurn == 1)
         *  return;*/

        int     x   = Random.Range(0, 10);
        int     y   = Random.Range(0, 10);
        Jobster jb  = GameObject.Find("jobster").GetComponent <Jobster>();
        Morpher mph = GameObject.Find("Morpher").GetComponent <Morpher>();

        //Debug.Log("enemy shot void");
        if (!jb.startedGame.Human.currentField.cells[x, y].IsShot)
        {
            jb.startedGame.Human.currentField.cells[x, y].IsShot = true;
            if (jb.startedGame.Human.currentField.cells[x, y].HasShip)
            {
                jb.startedGame.WhosTurn = 2;
                for (int i = 0; i < jb.startedGame.Human.ships.Length; i++)
                {
                    for (int j = 0; j < jb.startedGame.Human.ships[i].Size; j++)
                    {
                        Cell c = jb.startedGame.Human.ships[i].GetCell(j);
                        if (x == c.X && y == c.Y)
                        {
                            this.hp.x    = x;
                            this.hp.y    = y;
                            this.justHit = true;
                            jb.startedGame.Human.ships[i].ShotIncrease();
                            mph.InstShotCell(x, y, 1, 's');
                            this.hitShipSize  = jb.startedGame.Human.ships[i].Size;
                            this.hitShipIndex = i;
                            jb.PlayExplosion();
                            this.turnInProcess = false;
                            //this.ShootAfterHit();
                            return(0);
                        }
                    }
                }
            }
            else
            {
                //jb.startedGame.WhosTurn = 1;
                mph.InstShotCell(x, y, 1, 'm');
                jb.PlayMiss();
                this.turnInProcess = false;
                return(1);
            }
        }
        else
        {
            //jb.startedGame.WhosTurn = 2;
            this.turnInProcess = false;
            return(2);
        }

        return(3);
    }