void SetAdjacents()
 {
     for (int x = 0; x < GridSize.x; x++)
     {
         for (int z = 0; z < GridSize.z; z++)
         {
             //Create a new variable to be the
             // cell at position x, z.
             Transform cell;
             cell = Grid [x, z];
             //Create a new CellScript variable to
             // hold the cell's script component.
             CellScript cScript = cell.GetComponent <CellScript> ();
             //Detecting the cells' adjacents
             if (x - 1 >= 0)
             {
                 cScript.Adjacents.Add(Grid [x - 1, z]);
             }
             if (x + 1 < GridSize.x)
             {
                 cScript.Adjacents.Add(Grid [x + 1, z]);
             }
             if (z - 1 >= 0)
             {
                 cScript.Adjacents.Add(Grid [x, z - 1]);
             }
             if (z + 1 < GridSize.z)
             {
                 cScript.Adjacents.Add(Grid [x, z + 1]);
             }
             //Sort adjacents in ascending order
             cScript.Adjacents.Sort(SortByLowestWeight);
         }
     }
 }
Пример #2
0
 void SetAdjacents()
 {
     for (int x = 0; x < GridSize.x; x++)
     {
         for (int y = 0; y < GridSize.z; y++)
         {
             CellScript cScript = Grid [x, y].GetComponent <CellScript> ();
             if (x - 1 >= 0)
             {
                 cScript.Adjacents.Add(Grid [x - 1, y].transform);
             }
             if (x + 1 < GridSize.x)
             {
                 cScript.Adjacents.Add(Grid [x + 1, y].transform);
             }
             if (y - 1 >= 0)
             {
                 cScript.Adjacents.Add(Grid [x, y - 1].transform);
             }
             if (y + 1 < GridSize.z)
             {
                 cScript.Adjacents.Add(Grid [x, y + 1].transform);
             }
         }
     }
 }
Пример #3
0
    public bool everAliveReproduction = true; //true默认可以繁殖

    // Start is called before the first frame update
    void Start()
    {
        // Instantiate a 2D array
        grid = new CellScript[gridWidth, gridHeight];

        GameObject cellFather = new GameObject();

        cellFather.name = "cellFather";

        // Instantiate a grid of cubes ("cells") and position it according to its
        // place in the 2 dimensional array ("grid").
        for (int x = 0; x < gridWidth; x++)
        {
            for (int y = 0; y < gridHeight; y++)
            {
                Vector3    pos     = new Vector3(x * (cellDimension + padding), 0, y * (cellDimension + padding));
                GameObject cellObj = Instantiate(cellPrefab, pos, Quaternion.identity);
                cellObj.transform.SetParent(cellFather.transform);
                cellObj.transform.localScale = new Vector3(cellDimension, cellDimension, cellDimension);
                CellScript cs = cellObj.GetComponent <CellScript>();
                cs.possibilitiesOfAlive = possibilitiesOfEachCellBeingAlive;
                cs.x       = x;
                cs.y       = y;
                grid[x, y] = cs;
            }
        }
    }
Пример #4
0
    // Start is called before the first frame update
    void Start()
    {
        grid = new CellScript[gridWidth, gridHeight];

        //Using nested for loops, instantiate cubes with cell scripts in a way such that
        //	each cell will be places in a top left oriented coodinate system.
        //	I.e. the top left cell will have the x, y coordinates of (0,0), and the bottom right will
        //	have the coodinate (gridWidth-1, gridHeight-1)
        for (int x = 0; x < gridWidth; x++)
        {
            for (int y = 0; y < gridHeight; y++)
            {
                //Create a cube, position/scale it, add the CellScript to it.
                Vector3 pos = new Vector3(x * (cellDimension + cellSpacing),
                                          0,
                                          y * (cellDimension + cellSpacing));
                GameObject cellObj = Instantiate(cellPrefab, pos, Quaternion.identity);
                CellScript cs      = cellObj.AddComponent <CellScript>();
                cs.x     = x;
                cs.y     = y;
                cs.alive = (Random.value > 0.5f) ? true : false;
                cs.updateColor();

                cellObj.transform.position   = pos;
                cellObj.transform.localScale = new Vector3(cellDimension,
                                                           cellDimension,
                                                           cellDimension);
                //Finally add the cell to it's place in the two dimensional array
                grid[x, y] = cs;
            }
        }
        //Initialize the timer
        generationTimer = generationRate;
    }
Пример #5
0
    void GenerateSomeCells()
    {
        currentCells.Clear();
        CellScript[] cells = transform.GetComponentsInChildren <CellScript>();
        foreach (CellScript c in cells)
        {
            GameObject.Destroy(c.gameObject);
        }

        if (cellTemplate == null)
        {
            return;
        }
        currentRad = startingRad;
        for (int i = 0; i < numCells; ++i)
        {
            if (i > numCells / 4)
            {
                currentRad = startingRad * 1.5f;
            }

            Vector3    pos    = cellTemplate.transform.position;
            Vector3    offset = Random.onUnitSphere * currentRad;
            CellScript cs     = GameObject.Instantiate <CellScript>(cellTemplate, pos + offset, Quaternion.identity, this.transform);
            currentCells.Add(cs);
        }
    }
Пример #6
0
    public void Organise()
    {
        CollectChildren();
        foreach (GameObject GO in Children)
        {
            if (GO.GetComponent <CellScript>() != null)
            {
                CellScript cs = GO.GetComponent <CellScript>();
                //makes sure a mesh filter is connected
                if (cs.meshF == null)
                {
                    cs.meshF = cs.transform.gameObject.GetComponent <MeshFilter>();
                }

                //Sets the mesh
                if (cs.is_L_road)
                {
                    cs.meshF.mesh = meshL;
                }
                else if (cs.is_T_road)
                {
                    cs.meshF.mesh = meshT;
                }
                else if (cs.is_X_road)
                {
                    cs.meshF.mesh = meshX;
                }
                else if (cs.is_Straight_road)
                {
                    cs.meshF.mesh = meshStraight;
                }
            }
        }
    }
Пример #7
0
    public override void UseBonus(CellScript targetCell)
    {
        BoxScript bonusBox = targetCell.cellObject as BoxScript;

        if (bonusBox != null)
        {
            CheckCell(targetCell.topNeighbor);
            if (targetCell.topNeighbor != null)
            {
                CheckCell(targetCell.topNeighbor.leftNeighbor);
                CheckCell(targetCell.topNeighbor.rightNeighbor);
            }

            CheckCell(targetCell.bottomNeighbor);
            if (targetCell.bottomNeighbor != null)
            {
                CheckCell(targetCell.bottomNeighbor.leftNeighbor);
                CheckCell(targetCell.bottomNeighbor.rightNeighbor);
            }

            CheckCell(targetCell.leftNeighbor);
            CheckCell(targetCell.rightNeighbor);

            Instantiate(explosionPrefab, targetCell.transform.position, Quaternion.identity);
        }
        else
        {
            throw new UnityException("Бонусу передана ссылка на клетку не содержащую ящика");
        }
    }
    public List <string> GetList_of_Walls(CellScript cScript, Cell curCell) //Function used to determine the list of walls of the current cell.
    {
        List <string> neighbours = new List <string>();

        if (cScript.wallL.activeSelf == true)
        {
            neighbours.Add("LWall");
        }

        if (cScript.wallR.activeSelf == true)
        {
            neighbours.Add("RWall");
        }

        if (cScript.wallU.activeSelf == true)
        {
            neighbours.Add("UWall");
        }

        if (cScript.wallD.activeSelf == true)
        {
            neighbours.Add("DWall");
        }

        return(neighbours);
    }
Пример #9
0
    void OnTriggerStay(Collider other)
    {
        if (other.gameObject.layer == enemyLayer && other.tag == "Enemy")
        {
            CellScript enemy = other.GetComponent <CellScript>();

            Vector3 enemyPos = enemy.GetCurrentLocation();

            Vector3 normalizedForceVector = (transform.position - enemyPos).normalized;

            enemy.SetGravitating(true);

            enemy.ApplyForce(normalizedForceVector * gravitationForce);
        }
        else if (other.gameObject.layer == enemyBulletLayer)
        {
            BulletScript bullet = other.GetComponent <BulletScript>();

            Vector3 bulletPos = bullet.transform.position;

            Vector3 normalizedForceVector = (transform.position - bulletPos).normalized;

            bullet.SetGravitating(true);

            bullet.ApplyForce(normalizedForceVector * gravitationForce);
        }
    }
Пример #10
0
 public void Restore(CellScript cell)
 {
     cell.curCellState = curCellState;
     cell.gridPositionX = gridPositionX;
     cell.gridPositionY = gridPositionY;
     cell.instanceID = instanceID;
 }
Пример #11
0
    public void handleCellDamage(int damage, GridScript.ExplodeType type, CellScript origin)
    {
        Debug.Log("Handing cell damage for " + gridPositionX + " " + gridPositionY);
        if (occupier != null) {
            Debug.Log ("Occupier isn't null");
            ShipScript ship = occupier.GetComponent<ShipScript>();
            //Do one for base as well
            BaseScript based = occupier.GetComponent<BaseScript>();
            if (ship != null )
            {
                Debug.Log ("Ship isn't null");
                if (type == GridScript.ExplodeType.Mine) {
                    Debug.Log("Mine damage");

                    ship.HandleDoubleHit(this,damage, origin);
                } else {
                    ship.HandleHit(this,damage);
                }
            }
            if (based != null)
            {
                based.HandleHit(this,damage);
            }

            //Occupier handles explosion
        }
    }
Пример #12
0
    public override void UseBonus(CellScript targetCell)
    {
        BoxScript targetBox = targetCell.cellObject as BoxScript;

        if (targetBox == null)
        {
            throw new UnityException("Бонусу передана ссылка на клетку не содержащую ящика");
        }
        else
        {
            for (int i = 0; i < GameFieldScript.instance.height; i++)
            {
                for (int j = 0; j < GameFieldScript.instance.width; j++)
                {
                    CellScript cell    = GameFieldScript.instance[i, j];
                    BoxScript  cellBox = cell.cellObject as BoxScript;
                    if (cellBox != null && cellBox.boxColor == targetBox.boxColor)
                    {
                        cellBox.DestroyBox();
                        Instantiate(sniperEffect, cell.transform.position, Quaternion.identity);
                    }
                }
            }
        }
    }
Пример #13
0
 //проверяет совпадает ли цвет данного ящика
 //с цветом ящика в клетке переданного в аргументе cell
 //возвращает true если цвет совпадает
 //возвращает false если:
 //- цвет не совпадает
 //- в клетке нет ящика
 //- клетки нет (cell равен null)
 //цвет сравнивается с цветом ящика для которого вызван метод
 private bool CompareColor(CellScript cell)
 {
     if (cell == null)
     {
         return(false);
     }
     else
     {
         BoxScript box = cell.cellObject as BoxScript;
         if (box == null)
         {
             return(false);
         }
         else
         {
             if (box.boxColor == boxColor)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
 }
Пример #14
0
    // Start is called before the first frame update
    void Start()
    {
        initValues();

        this.grid    = new CellScript[this.gridHeight, this.gridWidth];
        this.cubeObj = new GameObject[this.gridHeight, this.gridWidth];

        //Using nested for loops, instantiate cubes with cell scripts in a way such that
        //	each cell will be places in a top left oriented coodinate system.
        //	I.e. the top left cell will have the x, y coordinates of (0,0), and the bottom right will
        //	have the coodinate (gridHeight-1, gridWidth-1)
        for (int row = 0; row < this.gridHeight; row++)
        {
            for (int col = 0; col < this.gridWidth; col++)
            {
                //Create a cube, position/scale it, add the CellScript to it.
                Vector3 pos = new Vector3(row * (this.cellDimension + this.cellSpacing), 0, col * (this.cellDimension + this.cellSpacing));

                GameObject cellObj = Instantiate(this.cellPrefab, pos, Quaternion.identity);
                this.cubeObj[row, col] = Instantiate(this.cubePrefab, pos + new Vector3(0, 3.3f, 0), Quaternion.identity);

                CellScript cs = cellObj.AddComponent <CellScript>();
                cs.value = Random.Range(0, 2);                 //0 or 1
                cs.updateColor();

                cellObj.transform.position   = pos;
                cellObj.transform.localScale = new Vector3(cellDimension, cellDimension, cellDimension);
                //Finally add the cell to it's place in the two dimensional array
                this.grid[row, col] = cs;
            }
        }
        //Initialize the timer
        this.generationTimer = this.generationRate;
    }
Пример #15
0
    private static List <CellScript> AddToList(List <CellScript> cells, CellScript center)
    {
        int next, max = nbX * nbY;

        for (int i = -1; i < 2; i += 2)
        {
            // Index in the list = x + y*nbX;
            next = GridIndex(center.x + i, center.y);
            // If it exist (index < max) and is not already in the list
            if (next < max && next > -1 && !cells.Contains(grid[next]))
            {
                // Add it.
                cells.Add(grid[next]);
            }

            // Index in the list = x + y*nbX;
            next = GridIndex(center.x, center.y + i);
            // If it exist (index < max) and is not already in the list
            if (next < max && next > -1 && !cells.Contains(grid[next]))
            {
                // Add it.
                cells.Add(grid[next]);
            }
        }
        return(cells);
    }
Пример #16
0
 //корутина перемещающая объект в другую клетку
 //cell - клетка в которую будет производится перемещение
 //moveSpeed - скорость перемещения
 protected IEnumerator MoveToCell(CellScript cell, float moveSpeed)
 {
     if (moveSpeed <= 0)
     {
         throw new UnityException("Скорость не может быть меньшей либо равной 0 (moveSpeed = " + moveSpeed + ")");
     }
     moving = true;
     //по игровой механике объект "переходит" в клетку до того как завершится визуальный переход
     currCell.cellObject = null;
     currCell            = cell;
     currCell.cellObject = this;
     while (cell.transform.position != transform.position - offset)
     {
         float   deltaSpeed = moveSpeed * Time.deltaTime;
         Vector3 movement   = cell.transform.position - (transform.position - offset);
         if (movement.sqrMagnitude > deltaSpeed * deltaSpeed)
         {
             movement = movement.normalized * deltaSpeed;
             transform.Translate(movement);
         }
         else
         {
             transform.position = cell.transform.position + offset;
         }
         yield return(null); //продолжить в следующем update
     }
     EndMoveAction();
     moving = false;
 }
Пример #17
0
    public override void MoveShip(CellScript destCell, int local)
    {
        if (local == 1) {
            rpcScript.NetworkMoveShip(shipID, destCell.gridPositionX, destCell.gridPositionY);
            return;
        }

        // TODO: Check path for movement is valid
        Debug.Log ("Called MoveShip within Kamikaze Boat for " + player);
        DisplayMoveRange(false);
        CellScript validDestCell = checkValidMove(destCell, cells[0].gridPositionX, cells[0].gridPositionY);
        if (validDestCell != destCell) {
            Debug.Log ("Invalid path, moving up until collision");
            // De-select current cell for ship
            destCell = validDestCell;
        }
        CellScript curCellScript = cells[0];
        curCellScript.occupier = null;
        curCellScript.selected = false;
        curCellScript.available = true;
        curCellScript.curCellState = GameScript.CellState.Available;
        cells.Clear();

        // Select current cell for ship
        cells.Add(destCell);
        destCell.occupier = this.gameObject;
        destCell.available = false;
        destCell.curCellState = GameScript.CellState.Ship;
        destCell.selected = true;

        // Move ship to target cell
        moveTime = 0;
        StartCoroutine(MoveKamikazeBoat(destCell.transform.position));
        gameScript.EndTurn();
    }
Пример #18
0
    // Determines the adjacent cells of each cell in the grid.
    void SetAdjacents()
    {
        for (int x = 0; x < Size.x; x++)
        {
            for (int z = 0; z < Size.z; z++)
            {
                Transform cell;
                cell = Grid[x, z];
                CellScript cScript = cell.GetComponent <CellScript>();

                if (x - 1 >= 0)
                {
                    cScript.Adjacents.Add(Grid[x - 1, z]);
                }
                if (x + 1 < Size.x)
                {
                    cScript.Adjacents.Add(Grid[x + 1, z]);
                }
                if (z - 1 >= 0)
                {
                    cScript.Adjacents.Add(Grid[x, z - 1]);
                }
                if (z + 1 < Size.z)
                {
                    cScript.Adjacents.Add(Grid[x, z + 1]);
                }

                cScript.Adjacents.Sort(SortByLowestWeight);
            }
        }
    }
Пример #19
0
 public CellSaverScript(CellScript cell)
 {
     curCellState = cell.curCellState;
     gridPositionX = cell.gridPositionX;
     gridPositionY = cell.gridPositionY;
     instanceID = cell.instanceID;
 }
Пример #20
0
    public void LoadJson()
    {
        if (inputFileName.text == "")
        {
            Debug.Log("请输入存档名字");
            taostScript.SetTaost("请输入存档名字");
            return;
        }
        jsonFullName = jsonDirectory + "/" + inputFileName.text + ".json";
        if (File.Exists(jsonFullName))
        {
            Debug.Log("存档文件存在,开始读取");
            taostScript.SetTaost("存档文件存在,开始读取");
            foreach (GameObject old in obj_cells)//先清空
            {
                old.SetActive(false);
                Destroy(old, 1);
            }
            obj_cells.Clear();
            JsonEdit.layerHeight = 0;
            JsonEdit.layerWeight = 0;
            JsonEdit.cellLoadNum = 0;
            content.sizeDelta    = new Vector2(1580, 830);

            StreamReader sr  = new StreamReader(jsonFullName);
            string       str = sr.ReadToEnd();
            sr.Close();
            sr.Dispose();

            wantCreateSon    = null;
            wantCreateSonId  = -1;
            wantLinkSon      = null;
            wantLinkSonId    = -1;
            wantFindNephew   = null;
            wantFindNephewId = -1;
            countScript.clearCount();

            jsonData             = JsonMapper.ToObject(str);
            cellIdNew            = int.Parse(jsonData["cellIdNew"] + "");
            ContentEdit.distance = float.Parse(jsonData["contentDis"] + "");
            content.localScale   = new Vector2(ContentEdit.distance, ContentEdit.distance);
            content.position     = new Vector2(float.Parse(jsonData["contentPosX"] + ""), float.Parse(jsonData["contentPosY"] + ""));
            content.sizeDelta    = new Vector2(float.Parse(jsonData["contentWidth"] + ""), float.Parse(jsonData["contentHeight"] + ""));
            jsonCells            = jsonData["cells"];
            LoadRootCell();
            cellCharacterId[0] = int.Parse(jsonData["hsId"] + "");
            cellCharacterId[1] = int.Parse(jsonData["vsId"] + "");
            cellCharacterId[2] = int.Parse(jsonData["pjId"] + "");
            cellCharacterId[3] = int.Parse(jsonData["pcId"] + "");
            cellCharacterId[4] = int.Parse(jsonData["leId"] + "");

            Debug.Log("读取完毕 cellIdNew " + cellIdNew);
        }
        else
        {
            Debug.Log("存档文件不存在");
            taostScript.SetTaost("存档文件不存在");
        }
    }
Пример #21
0
 // TODO : CanPlay = false here or in Character ?
 private void Unselect(bool played)
 {
     // if (played && selectedCell.target != null)
     //  selectedCell.target.canPlay = false;
     selectedCell.Unselect();
     selectedCell = null;
     CellManager.ResetGrid(ResetMode.normal);
 }
Пример #22
0
 private static void BresenhamLine(CellScript center, List <CellScript> cells)
 {
     // For all cell in cells
     // if cells.isinspellrange
     // draw a line
     // if it encounters a obstacle, set all following cells to false
     // end
 }
Пример #23
0
    public void Start()
    {
        GameObject cell = Instantiate(rootCell, transform);
        CellScript cs   = cell.GetComponent <CellScript>();

        cs.nextBranch = lowestBranch;
        cs.tree       = this;
    }
 // Use this for initialization
 void Start()
 {
     infected = false;
     myRenderer = GetComponent<Renderer>();
     colourBlend = 0.0f;
     parentScript = GetComponentInParent<CellScript>();
     type = parentScript.infectedType;
     cellGenes = parentScript.GetChromosome();
 }
Пример #25
0
 // Function disables wall of your choosing, pass it the script attached to the desired cell
 // and an 'ID', where the ID = the wall. 1 = left, 2 = right, 3 = up, 4 = down.
 public void RemoveWall(CellScript cScript, int wallID)
 {
     /**
      * if (wallID == 1) cScript.wallL.SetActive(false);
      * else if (wallID == 2) cScript.wallR.SetActive(false);
      * else if (wallID == 3) cScript.wallU.SetActive(false);
      * else if (wallID == 4) cScript.wallD.SetActive(false);
      */
 }
Пример #26
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Invoke ("FightEnable", 0.1f);
        CellScript otherCell = other.gameObject.GetComponent <CellScript> ();

        //	if ((Gender == 0 && Gender != otherCell.Gender) && (Random.value > 0.1f)) {
        if (Sexuality > Rage)
        {
            //Fighting = false;
            Collider2D MotherColl = GetComponent <Collider2D>();
            MotherColl.enabled = false;

            GameObject    man       = GameObject.Find("Manager");
            ManagerScript manScript = man.GetComponent <ManagerScript> ();

            //spawn a baby with values inherited in a random range between the values of mother and father
            manScript.BirthPosition   = transform.position + new Vector3(-RandomX * 2, -RandomY * 2, 0.0f);
            manScript.ChildHealth     = Random.Range(otherCell.Health, Health);
            manScript.ChildRage       = Random.Range(otherCell.Health, Health);
            manScript.ChildStrength   = Random.Range(otherCell.Strength, Strength);
            manScript.ChildSexuality  = Random.Range(otherCell.Sexuality, Sexuality);
            manScript.ChildSpeed      = Random.Range(otherCell.moveSpeed, moveSpeed);
            manScript.ChildPerception = Random.Range(otherCell.Perception, Perception);
            manScript.ChildID         = ID + otherCell.ID;
            manScript.ChildGenID      = GenerationID += 1;
            manScript.SpawnChild();
            Debug.Log(ID + " gave birth to " + otherCell.ID + "'s baby: " + manScript.ChildID + " generation " + manScript.ChildGenID);

            // transform the mother so it won't get eaten by the kid or the other way around
            Vector3 afterbirthPos = transform.position + new Vector3(RandomX * 2, RandomY * 2, 0.0f);
            transform.position = afterbirthPos;
            Sexuality         -= 1;
            Rage += 1;
            Invoke("NoImmunity", 0.5f);
        }
        else
        {
            if (Strength > otherCell.Strength)
            {
                Health += otherCell.Health / 2;
                //Strength += 1;
                Debug.Log(ID + " killed " + otherCell.ID);
                if (Health < 100)
                {
                    transform.localScale = new Vector3(Health, Health, 0);
                }
                else
                {
                    Health = 100;
                    transform.localScale = new Vector3(Health, Health, 0);
                }
                Destroy(other.gameObject);
                Rage      -= 1;
                Sexuality += 1;
            }
        }
    }
Пример #27
0
    //проверяет клетку на наличие в ней ящика
    //если ящик есть, то он уничтожается
    private void CheckCell(CellScript cell)
    {
        bool hasBox = cell != null && cell.cellObject is BoxScript;

        if (hasBox)
        {
            ((BoxScript)cell.cellObject).DestroyBox();
        }
    }
Пример #28
0
    public void Register(CellScript c)
    {
        Pos p = new Pos(c);

        if (!_Children.ContainsKey(p))
        {
            _Children.Add(p, c);
        }
    }
Пример #29
0
 public void SetDelPanel(CellScript _nowCell, Vector2 pos)
 {
     this.gameObject.SetActive(true);
     nowCell = _nowCell;
     this.transform.position = pos;
     button[0].interactable  = true;
     button[1].interactable  = true;
     button[2].interactable  = true;
 }
Пример #30
0
    void SpawnNucleus(CellScript inputCell)
    {
        GameObject    newNucleus = (GameObject)Instantiate(nucleus, inputCell.transform.position, inputCell.transform.rotation);
        NucleusScript script     = newNucleus.GetComponent <NucleusScript>();

        script.SetChromosome(inputCell.GetChromosome());
        script.SetVelocity(inputCell.velocity);
        script.attachedToCell = false;
    }
 // Use this for initialization
 void Start()
 {
     infected     = false;
     myRenderer   = GetComponent <Renderer>();
     colourBlend  = 0.0f;
     parentScript = GetComponentInParent <CellScript>();
     type         = parentScript.infectedType;
     cellGenes    = parentScript.GetChromosome();
 }
Пример #32
0
    private void Select(CellScript cell)
    {
        if (cell.target.canPlay)
        {
            selectedCell = cell;
            cell.Select();

            CellManager.ShowMoveRange(selectedCell);
        }
    }
Пример #33
0
    private bool DistanceCheck(CellScript cell)
    {
        Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(0) & Vector2.Distance(cell.Pos, mousePos) < CellScript.Radius)
        {
            return(true);
        }
        return(false);
    }
Пример #34
0
    private void CreateTeam(out CellScript currentObj, Color nodeColor)
    {
        Image endNodeS;

        currentObj = Instantiate(endCell);
        currentObj.EndNodeColor = nodeColor;
        endNodeS       = Instantiate(endNodeSymbol, currentObj.transform);
        endNodeS.color = nodeColor;
        endNodeS.transform.SetParent(currentObj.transform);
    }
Пример #35
0
    public void CreateInfectedCell(Chromosome _inputChromosome, Vector3 _location)
    {
        GameObject newCell = (GameObject)Instantiate(cell, _location, transform.rotation);
        CellScript script  = newCell.GetComponent <CellScript>();

        script.manager = this;
        script.CreateInfected(_inputChromosome);

        infectedList.Add(script);
    }
Пример #36
0
    public void CreateCell(CellScript newCell)
    {
        newCell.name = "cell " + totalBirths;
        cells.Add(newCell);

        while (cells.Count > numberOfCells)
        {
            CellScript cellScript = cells[0];
            GameObject.Destroy(cellScript.gameObject);
            cells.Remove(cellScript);
        }
        totalBirths++;
        Debug.Log("Birthrate = " + totalBirths / totalTime);
    }
Пример #37
0
 public override void Detonate(CellScript targetCell, int local)
 {
     if (local == 1) {
         DisplayCannonRange(false);
         rpcScript.DetonateKamikaze(targetCell.gridPositionX, targetCell.gridPositionY, shipID);
         return;
     }
     gridScript.Explode(targetCell.gridPositionX, targetCell.gridPositionY, GridScript.ExplodeType.Kamikaze);
     // Destroy kamikaze ship
     gameScript.ships.Remove(this);
     foreach (CellScript c in cells)
     {
         c.available = true;
         c.occupier = null;
         c.isVisible = false;
         c.curCellState = GameScript.CellState.Available;
     }
     Destroy(gameObject);
 }
Пример #38
0
 // Adds given cell to current selection - returns FALSE if not a valid selection
 public bool AddToSelection(CellScript cell)
 {
     bool valid = false;
     if (currentSelection.Count > 0) {
         List<CellScript> neighbours = GetCellNeighbours(cell);
         foreach (CellScript oCellScript in currentSelection) {
             if (neighbours.Contains(oCellScript)) {
                 valid = true;
             }
         }
     } else {
         valid = true;
     }
     if (valid == true) {
         currentSelection.Add(cell);
         return true;
     } else {
         return false;
     }
 }
Пример #39
0
    /*
     * Fire cannon at targeted cell
     */
    public void FireCannon(CellScript targetCell, int local)
    {
        // Call coroutine to display fire outcome
        if (local == 1) {
            rpcScript.fireCannonCell(shipID,targetCell.gridPositionX, targetCell.gridPositionY);
            return;
        }
        DisplayCannonRange(false);
        StartCoroutine(DisplayHit(targetCell.gameObject));

        if (targetCell.curCellState != GameScript.CellState.Available)
        {
            Debug.Log ("Hit Something at " +targetCell.gridPositionX + ", " + targetCell.gridPositionY);
            gameScript.NotifyDetonation("Cannon",targetCell);
            if (targetCell.curCellState == GameScript.CellState.Mine) {
                // Remove mine at this cell
                targetCell.curCellState = GameScript.CellState.Available;
                int centerX = targetCell.gridPositionX;
                int centerY = targetCell.gridPositionY;
                for (int x = (centerX > 0 ? centerX-1 : centerX); x <= centerX+1 && x < gridScript.grid.GetLength(0); x++) {
                    for (int y = (centerY > 0 ? centerY-1 : centerY); y <= centerY+1 && y < gridScript.grid.GetLength(1); y++) {
                        if (gridScript.grid[x,y].curCellState == GameScript.CellState.Available && gridScript.grid[x,y].curCellState != GameScript.CellState.Reef) {
                            //grid[x,y].curCellState = GameScript.CellState.MineRadius;
                            gridScript.grid[x,y].isMineRadius = false;
                            gridScript.grid[x,y].mineParentCell = null;
                        }
                    }
                }
            }
        } else {
            Debug.Log ("Hit Nothing");
            gameScript.messages = "Hit Nothing";
        }

        Debug.Log("Ending turn after shootin");
        gameScript.EndTurn();
        //rpcScript.EndTurn();
    }
Пример #40
0
 // Returns the neighbours of the given cell in the grid
 public List<CellScript> GetCellNeighbours(CellScript cell)
 {
     List<CellScript> neighbours = new List<CellScript>();
     for (int i = 0; i < grid.GetLength(0); i++) {
         for (int j = 0; j < grid.GetLength(1); j++) {
             if (grid[i,j] == cell) {
                 if (i-1 >= 0) neighbours.Add(grid[i-1, j]);
                 if (j-1 >= 0) neighbours.Add(grid[i, j-1]);
                 if (i < grid.GetLength(0)) neighbours.Add(grid[i+1, j]);
                 if (j < grid.GetLength(1)) neighbours.Add(grid[i, j+1]);
             }
         }
     }
     return neighbours;
 }
Пример #41
0
 /*
  * Returns the cells in a given rectangle on the grid, for the purposes of moving,
  * torpedo intersecting, and radar searching.
  */
 public CellScript[,] GetCellsInRange(int positionX, int positionY, int dx, int dy)
 {
     CellScript[,] cells = new CellScript[dx, dy];
     for (int x = 0; x < dx; x++) {
         for (int y = 0; y < dy; y++) {
             cells[x, y] = grid[positionX+x, positionY+y];
         }
     }
     return cells;
 }
Пример #42
0
 // Removes given cell from current selection - if cell is not in selection, does nothing
 public void RemoveFromSelection(CellScript cell)
 {
     if (currentSelection.Contains(cell)) currentSelection.Remove(cell);
 }
Пример #43
0
 public void InfectNeutralCell(CellScript _neutralCell)
 {
     friendlyList.Remove(_neutralCell);
     infectedList.Add(_neutralCell);
 }
Пример #44
0
 void SpawnNucleus(CellScript inputCell)
 {
     GameObject newNucleus = (GameObject)Instantiate(nucleus, inputCell.transform.position, inputCell.transform.rotation);
     NucleusScript script = newNucleus.GetComponent<NucleusScript>();
     script.SetChromosome(inputCell.GetChromosome());
     script.SetVelocity(inputCell.velocity);
     script.attachedToCell = false;
 }
Пример #45
0
 /** HELPER METHODS **/
 private void InitializeShipCell(CellScript cell, GameObject ship)
 {
     cell.occupier = ship;
     cell.selected = false;
     cell.available = false;
     cell.curCellState = GameScript.CellState.Ship;
     cell.DisplaySelection();
 }
Пример #46
0
    /*
     * Handles movement of ship
     * Moves ship to target cell
     */
    public virtual void MoveShip(CellScript destCell, int local)
    {
        // Get front cell of ship

        if (local == 1) {
            rpcScript.NetworkMoveShip(shipID, destCell.gridPositionX, destCell.gridPositionY);
            return;
        }
        bool isMineLayer = false;
        if (this.shipType == "minelayer") { isMineLayer = true;}

        Debug.Log("cell count: "+ cells.Count.ToString());
        CellScript frontCellScript = cells[cells.Count - 1];
        int startX = frontCellScript.gridPositionX;
        int startY = frontCellScript.gridPositionY;
        CellScript backCellScript = cells[0];
        int backX = backCellScript.gridPositionX;
        int backY = backCellScript.gridPositionY;
        // Calculate distance to movement cell
        int distance = 0;
        bool forward = false;
        bool triggerMine = false;
        GameScript.CellState previousState = GameScript.CellState.Available;

        if (curDir == GameScript.Direction.East || curDir == GameScript.Direction.West) {
            if (destCell.gridPositionY < startY) destCell = gridScript.GetCell(backX, backY - 1);
            else if (destCell.gridPositionY > startY) destCell = gridScript.GetCell(backX, backY + 1);
            else {

                distance = destCell.gridPositionX - startX;
            }
        } else {
            if (destCell.gridPositionX < startX) destCell = gridScript.GetCell(backX - 1, backY);
            else if (destCell.gridPositionX > startX) destCell = gridScript.GetCell(backX + 1, backY);
            else distance = destCell.gridPositionY - startY;
        }

        if (curDir == GameScript.Direction.West || curDir == GameScript.Direction.South) {
            distance = -distance;
        }

        // Distance will be 0 only if the move is sideways
        if (distance == 0) {
        //			bool validMove = gridScript.VerifySidewaysMove(destCell.gridPositionX, destCell.gridPositionY, shipSize, curDir,isMineLayer);
            List<CellScript> validMove = gridScript.VerifySidewaysMove(destCell.gridPositionX, destCell.gridPositionY, shipSize, curDir,isMineLayer);

            //rear most cell
            bool doNotMove = false;
            bool isMine= false;

            CellScript tCell = destCell;

            foreach (CellScript c in validMove) {
                if (!c.available) {
                    //Do not move
                    gameScript.GlobalNotify("Collision at (" +destCell.gridPositionX +","+destCell.gridPositionY+")");
                    return;
                }

                if (c.isMineRadius) {
                    if (!isMineLayer) {
                        Debug.Log ("Not mine layer. CHecking hit");
                        isMine = true;
                        triggerMine = true;
                        tCell = c;
                    }
                }
            }
            moveTime = 0;
            StartCoroutine(MoveShipSideways(destCell.transform.position));
            destCell = tCell;

        } else if (distance < 0) {
            if (!destCell.available) {
                //Do not move
                gameScript.GlobalNotify("Collision at (" +destCell.gridPositionX +","+destCell.gridPositionY+")");
                return;
            }
            if (destCell.isMineRadius) {
                if (!isMineLayer) {
                    triggerMine = true;
                }
            }
        //			bool validMove = gridScript.VerifyCell(destCell.gridPositionX, destCell.gridPositionY);
        //			if (!validMove) {
        //				return;
        //			}
            moveTime = 0;
            StartCoroutine(MoveShipBackward());
        } else {
            // Verify that destination cell is within correct range
            if (distance > speed) {
                Debug.Log ("Cannot move that far");
                return;
            }

            CellScript validDestCell = gridScript.VerifyCellPath(startX, startY, distance, curDir, destCell, "mine",isMineLayer);
            if (validDestCell.isMineRadius && !isMineLayer) {
                // Go here and explode
                triggerMine = true;
                previousState = destCell.curCellState;
                destCell = validDestCell;
            }
            if (!validDestCell.isMineRadius && isMineLayer) {
                // Not a mine radius
                if (validDestCell.curCellState == GameScript.CellState.Available) {
                    destCell = validDestCell;
                } else {
                    gameScript.GlobalNotify("Collision at (" +destCell.gridPositionX +","+destCell.gridPositionY+")");
                    destCell = gridScript.VerifyCellPath(startX, startY, distance, curDir, destCell, "Move",isMineLayer);
                }
            } else {
                if (validDestCell.curCellState == GameScript.CellState.Available) {
                    destCell = validDestCell;
                } else {
                    gameScript.GlobalNotify("Collision at (" +destCell.gridPositionX +","+destCell.gridPositionY+")");
                    destCell = gridScript.VerifyCellPath(startX, startY, distance, curDir, destCell, "Move",isMineLayer);
                }
            }

            forward = true;
            moveTime = 0;
            StartCoroutine(MoveShipForward(destCell.transform.position));
        }
        DisplayMoveRange(false);

        // Update occupied cells
        // Reset currently occupied cells
        foreach (CellScript oCellScript in cells) {
            oCellScript.occupier = null;
            oCellScript.selected = false;
            oCellScript.available = true;
            oCellScript.curCellState = GameScript.CellState.Available;
            //oCellScript.DisplaySelection();
        }
        cells.Clear();

        // Get new cell that ship is on
        CellScript shipCell = destCell;
        int shipX = shipCell.gridPositionX;
        int shipY = shipCell.gridPositionY;
        Debug.Log ("Ship Vals: " + shipX + " " + shipY);
        // Add newly occupied cells
        switch(curDir) {
        case GameScript.Direction.East:
            if (forward) shipX -= shipSize-1;
            //Debug.Log ("Ship Vals: " + shipX + " " + shipY);
            for (int i = 0; i < shipSize; i++) {
                //Debug.Log ("i: " + i);
                CellScript newCellScript = gridScript.grid[shipX + i, shipY];
                //Debug.Log ("Cell: " + newCellScript.gridPositionX + " " + newCellScript.gridPositionY);
                newCellScript.occupier = this.gameObject;
                cells.Add(newCellScript);
            }
            break;
        case GameScript.Direction.North:
            if (forward) shipY -= shipSize-1;
            Debug.Log ("Ship Vals: " + shipX + " " + shipY);
            for (int i = 0; i < shipSize; i++) {
                Debug.Log ("i: " + i);
                CellScript newCellScript = gridScript.grid[shipX, shipY + i];
                Debug.Log ("Cell: " + newCellScript.gridPositionX + " " + newCellScript.gridPositionY);
                newCellScript.occupier = this.gameObject;
                cells.Add(newCellScript);
            }
            break;
        case GameScript.Direction.South:
            if (forward) shipY += shipSize-1;
            Debug.Log ("Ship Vals: " + shipX + " " + shipY);
            for (int i = 0; i < shipSize; i++) {
                Debug.Log ("i: " + i);
                CellScript newCellScript = gridScript.grid[shipX, shipY - i];
                Debug.Log ("Cell: " + newCellScript.gridPositionX + " " + newCellScript.gridPositionY);
                newCellScript.occupier = this.gameObject;
                cells.Add(newCellScript);
            }
            break;
        case GameScript.Direction.West:
            if (forward) shipX += shipSize-1;
            Debug.Log ("Ship Vals: " + shipX + " " + shipY);
            for (int i = 0; i < shipSize; i++) {
                Debug.Log ("i: " + i);
                CellScript newCellScript = gridScript.grid[shipX - i, shipY];
                Debug.Log ("Cell: " + newCellScript.gridPositionX + " " + newCellScript.gridPositionY);
                newCellScript.occupier = this.gameObject;
                cells.Add(newCellScript);
            }
            break;
        }

        foreach (CellScript oCellScript in cells) {
            //Debug.Log ("Index: " + cells.IndexOf(oCellScript) + " Position: " + oCellScript.gridPositionX + " " + oCellScript.gridPositionY);
            oCellScript.occupier = this.gameObject;
            oCellScript.available = false;
            oCellScript.curCellState = GameScript.CellState.Ship;
            oCellScript.selected = true;
        }

        //Debug.Log("X: "+ destCell.gridPositionX + " Y: " + destCell.gridPositionY);
        Debug.Log ("Trigger mine value is: " + triggerMine);
        if (triggerMine) {
            if (previousState == GameScript.CellState.Mine) {
                Debug.Log("Explode");
                gridScript.Explode(destCell.gridPositionX,destCell.gridPositionY,GridScript.ExplodeType.Mine);
            }
            if (destCell.isMineRadius) {
                CellScript mine = destCell.mineParentCell;
                Debug.Log("Explode");
                gridScript.Explode(mine.gridPositionX,mine.gridPositionY,GridScript.ExplodeType.Mine);
            }
        }

        // End the current turn
        //		gameScript.curGameState = GameScript.GameState.Wait;

        gameScript.EndTurn();
        //rpcScript.EndTurn();
    }
Пример #47
0
 public void PickupMine(CellScript cell, int local)
 {
     if (local == 1) {
         rpcScript.RemoveMine(cell.gridPositionX, cell.gridPositionY);
     }
     DisplayMineRange (false);
 }
Пример #48
0
 public void DisplayCellForShoot(bool status, CellScript cellScript)
 {
     Color setColor;
     if (status) setColor = Color.red;
     else setColor = Color.blue;
     if (status) cellScript.availableForShoot = true;
     else cellScript.availableForShoot = false;
     if (cellScript.curCellState == GameScript.CellState.Reef && !status)
         cellScript.renderer.material.color = Color.black;
     else cellScript.renderer.material.color = setColor;
 }
Пример #49
0
 public void HandleHit(CellScript cell, int damage)
 {
     int index = cells.IndexOf(cell);
     Debug.Log("Handing on index: "+index);
     HandleHit(baseSections[index],0,damage);
 }
Пример #50
0
 CellScript checkValidMove(CellScript destCell, int startX, int startY)
 {
     CellScript validDestCell = destCell;
     int destX = destCell.gridPositionX;
     int destY = destCell.gridPositionY;
     if (destY == startY) {
         if (destX < startX) {
             validDestCell = gridScript.VerifyCellPath(startX, startY, 2, GameScript.Direction.West, destCell, "Move", false);
         } else {
             // destX > startX
             validDestCell = gridScript.VerifyCellPath(startX, startY, 2, GameScript.Direction.East, destCell, "Move", false);
         }
     } else if (destX == startX) {
         if (destY < startY) {
             validDestCell = gridScript.VerifyCellPath(startX, startY, 2, GameScript.Direction.South, destCell, "Move", false);
         } else {
             // destY > startY
             validDestCell = gridScript.VerifyCellPath(startX, startY, 2, GameScript.Direction.North, destCell, "Move", false);
         }
     } else {
         // Check diagonals
         if (destX < startX && destY > startY) {
             // Upper left diagonal
             while (destX < startX-1 && destY > startY+1) {
                 if (!gridScript.VerifyCell(destX, destY)) {
                     validDestCell = gridScript.grid[destX, destY];
                 }
                 destX += 1;
                 destY -= 1;
             }
         }
         if (destX > startX && destY > startY) {
             // Upper right diagonal
             while (destX > startX+1 && destY > startY+1) {
                 if (!gridScript.VerifyCell(destX, destY)) {
                     validDestCell = gridScript.grid[destX, destY];
                 }
                 destX -= 1;
                 destY -= 1;
             }
         }
         if (destX < startX && destY < startY) {
             // Bottom left diagonal
             while (destX < startX-1 && destY < startY-1) {
                 if (!gridScript.VerifyCell(destX, destY)) {
                     validDestCell = gridScript.grid[destX, destY];
                 }
                 destX += 1;
                 destY += 1;
             }
         }
         if (destX > startX && destY < startY) {
             // Bottom right diagonal
             while (destX > startX+1 && destY < startY-1) {
                 if (!gridScript.VerifyCell(destX, destY)) {
                     validDestCell = gridScript.grid[destX, destY];
                 }
                 destX -= 1;
                 destY += 1;
             }
         }
     }
     return validDestCell;
 }
Пример #51
0
 public void AddMovingCell(CellScript curCell)
 {
     if (curCell)
     {
         _movingCells.Add(curCell);
     }
 }
Пример #52
0
 public void AddToKillList(CellScript npc)
 {
     infectedList.Remove(npc);
     killList.Add(npc);
 }
Пример #53
0
    public void RemoveMovingCell(CellScript curCell)
    {
        if (curCell && MainManager.instance)
        {
            _movingCells.Remove(curCell);

            if (_movingCells.Count == 0)
            {
                MainManager.instance.OnCellDroppedAndAdded();
            }
        }
    }
Пример #54
0
 public virtual void Detonate(CellScript targetCell, int local)
 {
 }
Пример #55
0
    /*
     * Returns the valid destination cell within the given path
     */
    public CellScript VerifyCellPath(int positionX, int positionY, int dist, GameScript.Direction dir, CellScript destCell, string type, bool isMineLayer)
    {
        bool obstacleEncountered = false;
        int offset = 0;
        if (type == "Move") offset = 1;
        CellScript encounteredObstacle = destCell;
        switch (dir) {
        case GameScript.Direction.East:
            for (int x = 1; x <= dist; x++) {
                if (positionX + x < 0 || positionX + x > 29) break;
                CellScript curCellScript = grid[positionX + x, positionY];
                // if mine then minelayer stops before, everyone else hits mineradius
                // if minelayer, minelayer goes through, everyone else stops
                // everything else stops minelayer

                if (isMineLayer) {
                    if (curCellScript.available != true) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX + (x-offset), positionY].GetComponent<CellScript>();
                        break;
                    }

                } else {
                    if (curCellScript.available != true || curCellScript.isMineRadius) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX + (x-offset), positionY].GetComponent<CellScript>();
                        break;
                    }
                }

        //				if (curCellScript.available != true || curCellScript.isMineRadius) {
        //						obstacleEncountered = true;
        //						encounteredObstacle = grid[positionX + (x-offset), positionY].GetComponent<CellScript>();
        //						break;
        //
        //				}
            }
            break;
        case GameScript.Direction.West:
            for (int x = 1; x <= dist; x++) {
                if (positionX - x < 0 || positionX - x > 29) break;
                CellScript curCellScript = grid[positionX - x, positionY];

                if (isMineLayer) {
                    if (curCellScript.available != true) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX - (x-offset), positionY].GetComponent<CellScript>();
                        break;
                    }

                } else {
                    if (curCellScript.available != true || curCellScript.isMineRadius) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX - (x-offset), positionY].GetComponent<CellScript>();
                        break;
                    }
                }
        //				if (curCellScript.available != true || curCellScript.isMineRadius) {
        //					obstacleEncountered = true;
        //					encounteredObstacle = grid[positionX - (x-offset), positionY].GetComponent<CellScript>();
        //					break;
        //				}
            }
            break;
        case GameScript.Direction.North:
            for (int y = 1; y <= dist; y++) {
                if (positionY + y < 0 || positionY + y > 29) break;
                CellScript curCellScript = grid[positionX, positionY + y];

                if (isMineLayer) {
                    if (curCellScript.available != true) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX, positionY + (y-offset)].GetComponent<CellScript>();
                        break;
                    }

                } else {
                    if (curCellScript.available != true || curCellScript.isMineRadius) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX, positionY + (y-offset)].GetComponent<CellScript>();
                        break;
                    }
                }
        //				if (curCellScript.available != true || curCellScript.isMineRadius) {
        //					obstacleEncountered = true;
        //					encounteredObstacle = grid[positionX, positionY + (y-offset)].GetComponent<CellScript>();
        //					break;
        //				}
            }
            break;
        case GameScript.Direction.South:
            for (int y = 1; y <= dist; y++) {
                if (positionY - y < 0 || positionY - y > 29) break;
                CellScript curCellScript = grid[positionX, positionY - y];

                if (isMineLayer) {
                    if (curCellScript.available != true) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX, positionY - (y-offset)].GetComponent<CellScript>();
                        break;
                    }

                } else {
                    if (curCellScript.available != true || curCellScript.isMineRadius) {
                        obstacleEncountered = true;
                        encounteredObstacle = grid[positionX, positionY - (y-offset)].GetComponent<CellScript>();
                        break;
                    }
                }
        //				if (curCellScript.available != true || curCellScript.isMineRadius) {
        //					obstacleEncountered = true;
        //					encounteredObstacle = grid[positionX, positionY - (y-offset)].GetComponent<CellScript>();
        //					break;
        //				}
            }
            break;
        }

        return encounteredObstacle;
    }
Пример #56
0
 public void HandleDoubleHit(CellScript cell, int damage, CellScript origin)
 {
     int index = cells.IndexOf(cell);
     int originIndex = cells.IndexOf(origin);
     Debug.Log ("Handling mine for index: "+ index);
     //Hits front of ship, then remove front and one behind.
     if (shipSize == 1) {
         HandleHit(shipSections[index],0,damage);
     } else if (index == shipSize - 1) {
         HandleHit(shipSections[index],0,damage);
         if ((index-1 >= 0)) {
             HandleHit(shipSections[index-1],0,damage);
         }
     } else {
         HandleHit(shipSections[index],0,damage);
         if ((index + 1) < shipSize) {
             HandleHit(shipSections[index+1],0,damage);
         }
     }
 }
Пример #57
0
 public void NotifyDetonation(string weapon, CellScript cell)
 {
     string message = "Hit nothing";
     if (cell != null) {
         switch (cell.curCellState) {
         case CellState.Available:
             message = "Hit nothing";
             break;
         case CellState.Base:
             message = "Hit player base";
             break;
         case CellState.Mine:
             message = "Mine Hit";
             break;
         case CellState.Ship:
             message = "Hit Ship";
             break;
         case CellState.Reef:
             message = "Hit reef";
             break;
         }
         message += " by a " + weapon + " at location (" + cell.gridPositionX + "," + cell.gridPositionY + ")";
         Debug.Log (message);
     }
     else Debug.Log ("Notify Detonation was passed a null cell.");
     GlobalNotify (message);
 }