예제 #1
0
 public GridTileOccupant(GameObject obj, OccupantType type)
 {
     this.obj = obj;
     rotation = Quaternion.identity;
     scale    = Vector3.one;
     this.windEffectController = obj.GetComponent <WindEffectController>();
     this.type = type;
 }
예제 #2
0
 public static GameObject GetObject(OccupantType occupantType)
 {
     if (!pools.ContainsKey(occupantType))
     {
         throw new ArgumentException("There is no pool for objects of type " + occupantType);
     }
     return(pools [occupantType].GetObject());
 }
예제 #3
0
    public float desiredTemperature = 21f;                      //in °C

//	public Occupant() //everything is default, in the other constructor, so this one's irrelevant
//	{
//
//	} //End.Occupant() - constructor

    public Occupant(OccupantType oType = OccupantType.Visitor, string name = "New occupant",
                    float weight       = 70f, Room room = null)
    {
        occupantGuid        = new Guid();
        occupantType        = oType;
        occupantName        = name;
        occupantWeight      = weight;
        occupantCurrentRoom = room;
    }     //End.Occupant() - constructor overload
예제 #4
0
 public GridTileOccupant(GameObject obj, Vector3 position, Quaternion rotation, Vector3 scale, OccupantType type)
 {
     this.obj                  = obj;
     this.position             = position;
     this.rotation             = rotation;
     this.scale                = scale;
     this.terrainObject        = obj.GetComponent <TerrainObject>();
     this.windEffectController = obj.GetComponent <WindEffectController>();
     this.type                 = type;
 }
예제 #5
0
 public static void AddPool(OccupantType occupantType, GameObject prefab, int size, bool resizable)
 {
     if (!pools.ContainsKey(occupantType))
     {
         pools.Add(occupantType, new GameObject("ObjectPool_" + occupantType.ToString())
                   .AddComponent <GameobjectPool>());
         pools [occupantType].Setup(prefab, size, resizable);
     }
     else
     {
         throw new ArgumentException("A pool already exists for " + occupantType);
     }
 }
예제 #6
0
 private static bool CheckColWin(OccupantType occupantType, int[,] state)
 {
     // Given an occupant type, check all column to see if that occupant type has won any column
     for (int i = 0; i < 3; i++)
     {
         if (state[0, i] == (int)occupantType &&
             state[1, i] == (int)occupantType &&
             state[2, i] == (int)occupantType)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #7
0
 private static bool CheckRowWin(OccupantType occupantType, int[,] state)
 {
     // Given an occupant type, check all rows to see if that occupant type has won any row
     for (int i = 0; i < 3; i++)
     {
         if (state[i, 0] == (int)occupantType &&
             state[i, 1] == (int)occupantType &&
             state[i, 2] == (int)occupantType)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #8
0
 private static bool CheckDiagWin(OccupantType occupantType, int[,] state)
 {
     // Given an occupant type, check both diagonals  to see if that occupant type has won any diagonal
     if (state[0, 0] == (int)occupantType &&
         state[1, 1] == (int)occupantType &&
         state[2, 2] == (int)occupantType)
     {
         return(true);
     }
     if (state[2, 0] == (int)occupantType &&
         state[1, 1] == (int)occupantType &&
         state[0, 2] == (int)occupantType)
     {
         return(true);
     }
     return(false);
 }
예제 #9
0
 public static bool IsEntirelyInactive(OccupantType occupantType)
 {
     return(pools [occupantType].IsEntirelyInactive());
 }
예제 #10
0
 public static bool ContainsKey(OccupantType occupantType)
 {
     return(pools.ContainsKey(occupantType));
 }
예제 #11
0
        private static MinimaxMove Minimax(TicTacToeState state, OccupantType player)
        {
            var emptyIndices = EmptyIndices(state);

            var winningResult = WinCheckUtil.Check(state);

            if (winningResult.Winner.Equals(GameWinnerType.PLAYER))
            {
                return(new MinimaxMove {
                    Score = -10
                });
            }
            else if (winningResult.Winner.Equals(GameWinnerType.AI))
            {
                return(new MinimaxMove {
                    Score = 10
                });
            }
            else if (emptyIndices.Count == 0)
            {
                return(new MinimaxMove {
                    Score = 0
                });
            }

            var moves = new List <MinimaxMove>();

            for (int i = 0; i < emptyIndices.Count; i++)
            {
                var move = new MinimaxMove
                {
                    Index = emptyIndices[i]
                };

                state.Data[emptyIndices[i]] = (int)player;

                var result = player.Equals(OccupantType.AI) ?
                             Minimax(state, OccupantType.PLAYER) :
                             Minimax(state, OccupantType.AI);
                move.Score = result.Score;

                state.Data[emptyIndices[i]] = (int)OccupantType.NONE;

                moves.Add(move);
            }

            int bestMove = -1;

            if (player.Equals(OccupantType.AI))
            {
                var bestScore = -10000;
                for (int i = 0; i < moves.Count; i++)
                {
                    if (moves[i].Score > bestScore)
                    {
                        bestScore = moves[i].Score;
                        bestMove  = i;
                    }
                }
            }
            else
            {
                var bestScore = 10000;
                for (int i = 0; i < moves.Count; i++)
                {
                    if (moves[i].Score < bestScore)
                    {
                        bestScore = moves[i].Score;
                        bestMove  = i;
                    }
                }
            }

            return(moves[bestMove]);
        }
 public Occupant(OccupantType type, int?age)
 {
     Type = type;
     Age  = age;
 }
예제 #13
0
 public ThreeDoors(OccupantType o1, OccupantType o2, OccupantType o3)
 {
     Door1 = new Door(1, o1);
     Door2 = new Door(2, o2);
     Door3 = new Door(3, o3);
 }
예제 #14
0
 public Door(int id, OccupantType occ)
 {
     Id       = id;
     Occupant = occ;
 }