Esempio n. 1
0
    private void OnCellStatusChanges(Cell c, Cell.CellStatus prev)
    {
        if (!this.colors.ContainsKey(c.Status))
        {
            throw new UnityException("Missing color for state " + c.Status);
        }

        this.UpdateColor();
    }
Esempio n. 2
0
 public MoveHeuristic(Player.Color Me)
 {
     if (Me.Equals(Player.Color.Red))
     {
         MyStatus       = Cell.CellStatus.OccupiedRed;
         OpponentStatus = Cell.CellStatus.OccupiedBlack;
     }
     else
     {
         MyStatus       = Cell.CellStatus.OccupiedBlack;
         OpponentStatus = Cell.CellStatus.OccupiedRed;
     }
 }
Esempio n. 3
0
 private void setUpColors()
 {
     if (GameBoard.UserPlayer.PlayerColor == Player.Color.Red)
     {
         userColor     = Cell.CellStatus.OccupiedRed;
         computerColor = Cell.CellStatus.OccupiedBlack;
     }
     else
     {
         userColor     = Cell.CellStatus.OccupiedBlack;
         computerColor = Cell.CellStatus.OccupiedRed;
     }
 }
Esempio n. 4
0
 private void OnCellStatusChanges(Cell c, Cell.CellStatus prev)
 {
     if (Cell.CellStatus.Alive != prev && Cell.CellStatus.Alive == c.Status)
     {
         if (null != this.OnCellBirth)
         {
             this.OnCellBirth(c);
         }
     }
     else if (Cell.CellStatus.Alive == prev && Cell.CellStatus.Alive != c.Status)
     {
         if (null != this.OnCellDeath)
         {
             this.OnCellDeath(c);
         }
     }
 }
Esempio n. 5
0
    void AssignGeneToTile(int x, int y, int gene, Cell.CellStatus status)
    {
        Debug.Assert(textures != null);
        Debug.Assert(cells != null);

        cells[x, y].Gene   = Extensions.Clamp(gene, GeneSet.MinGene, GeneSet.MaxGene);
        cells[x, y].Status = status;

        int textureX = (x * GeneSet.width) / PNGSize;
        int textureY = (y * GeneSet.height) / PNGSize;

        int chunkX = (x * GeneSet.width) % PNGSize;
        int chunkY = (y * GeneSet.height) % PNGSize;

        Texture2D t;
        Rect      r;

        switch (status)
        {
        case Cell.CellStatus.Normal:
        {
            t = GeneSet.GetSpriteFromGene(cells[x, y].Gene).texture;
            r = GeneSet.GetSpriteFromGene(cells[x, y].Gene).textureRect;
            break;
        }

        case Cell.CellStatus.Collision:
        {
            t = GeneSet.Collision.texture;
            r = GeneSet.Collision.textureRect;
            break;
        }

        default:
        {
            t = GeneSet.Empty.texture;
            r = GeneSet.Empty.textureRect;
            break;
        }
        }

        textures[textureX, textureY].SetPixels(chunkX, chunkY,
                                               GeneSet.width, GeneSet.height,
                                               t.GetPixels((int)r.x, (int)r.y, (int)r.width, (int)r.height));
    }