Changeset 4671 for 2013/30


Ignore:
Timestamp:
2013-07-25 14:58:28 (6 years ago)
Author:
dezhidki
Message:

Talletus.

Location:
2013/30/DenisZ/CastleMaster/CastleMaster
Files:
6 added
15 edited

Legend:

Unmodified
Added
Removed
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/CastleMaster.csproj

    r4646 r4671  
    7474  </ItemGroup> 
    7575  <ItemGroup> 
     76    <Compile Include="Ai\AIStates\AgressiveState.cs" /> 
     77    <Compile Include="Ai\AIStates\AIState.cs" /> 
     78    <Compile Include="Ai\AIStates\CollectiveState.cs" /> 
     79    <Compile Include="Ai\AIStates\DefensiveState.cs" /> 
    7680    <Compile Include="Ai\AStar.cs" /> 
    7781    <Compile Include="Ai\Node.cs" /> 
     
    8387    <Compile Include="Entities\TileEntities\TileEntityBlock.cs" /> 
    8488    <Compile Include="Entities\TileEntities\TileEntityTree.cs" /> 
    85     <Compile Include="Graphics\AnimationHelper.cs" /> 
     89    <Compile Include="Graphics\TimerHelper.cs" /> 
    8690    <Compile Include="Graphics\Camera.cs" /> 
    8791    <Compile Include="Graphics\RenderHelper.cs" /> 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Entities/Entity.cs

    r4646 r4671  
    163163        } 
    164164 
     165        public float DistanceTo(float x, float z) 
     166        { 
     167            float xd = X - x; 
     168            float zd = Z - z; 
     169 
     170            return (float)(Math.Sqrt(xd * xd + zd * zd)); 
     171        } 
     172 
     173        public float DistanceToSqr(float x, float z) 
     174        { 
     175            float xd = X - x; 
     176            float zd = Z - z; 
     177 
     178            return xd * xd + zd * zd; 
     179        } 
     180 
    165181        public virtual void Update() { } 
    166182 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Game.cs

    r4646 r4671  
    6464            graphics.PreferredBackBufferWidth = WIDTH; 
    6565            graphics.PreferredBackBufferHeight = HEIGHT; 
    66             graphics.SynchronizeWithVerticalRetrace = false; 
     66            graphics.SynchronizeWithVerticalRetrace = true; 
    6767            graphics.ApplyChanges(); 
    6868            Window.Title = TITLE; 
     
    128128            camera = new Camera(level); 
    129129            AddPlayer(new PlayerReal(TEAM1, level, camera)); 
    130             AddPlayer(new PlayerAI(TEAM2, level, camera)); 
     130            AddPlayer(new PlayerAI(TEAM2, level, camera, PlayerAI.DIFFICULTY_HARD, players[0])); 
    131131            level.InitLevel(); 
     132            foreach (Player p in players) 
     133                if (p != null) p.OnLevelLoaded(); 
    132134            camera.CenterOn(level.Width / 2 * Viewport.TILESIZE, level.Height / 2 * Viewport.TILESIZE); 
    133135        } 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Players/Player.cs

    r4592 r4671  
    66using CastleMaster.Graphics; 
    77using CastleMaster.Units; 
     8using Microsoft.Xna.Framework; 
    89 
    910namespace CastleMaster.Players 
     
    1112    public abstract class Player 
    1213    { 
     14        public const int LUMBER_WORTH = 2; 
     15        public const int START_MONEY = 20; 
     16        public const int START_LUMBER = 10; 
     17 
    1318        protected Team team; 
    1419        protected Level level; 
    1520        protected Camera camera; 
     21        protected UnitKing king; 
     22        protected UnitStore store; 
    1623 
    1724        public Player(Team team, Level level, Camera camera) 
     
    2027            this.level = level; 
    2128            this.camera = camera; 
     29            LumberAmount = START_LUMBER; 
     30            CoinsAmount = 20; 
     31 
     32            king = new UnitKing(level, this); 
     33            store = new UnitStore(level, this); 
    2234        } 
     35 
     36        public Point HomePoint { get; set; } 
     37 
     38        public Point WoodcutterSpawnPoint { get; set; } 
     39 
     40        public Point WarriorSpawnPoint { get; set; } 
     41 
     42        public Point RangerSpawnPoint { get; set; } 
     43 
     44        public UnitKing King { get { return king; } } 
     45 
     46        public UnitStore Store { get { return store; } } 
     47 
     48        public List<Unit> AvailableUnits { get { return level.Units[Team.ID]; } } 
     49 
     50        public int CoinsAmount { get; set; } 
     51 
     52        public int LumberAmount { get; set; } 
    2353 
    2454        public Level Level { get { return level; } } 
     
    2757 
    2858        public Team Team { get { return team; } } 
     59 
     60        public virtual void OnLevelLoaded() { } 
     61 
     62        public List<T> GetUnitsByType<T>() where T : Unit 
     63        { 
     64            List<T> result = new List<T>(); 
     65 
     66            foreach (Unit u in AvailableUnits) 
     67                if (typeof(T).IsAssignableFrom(u.GetType())) 
     68                    result.Add((T)u); 
     69 
     70            return result; 
     71        } 
    2972 
    3073        public virtual void Update() 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Players/PlayerAI.cs

    r4592 r4671  
    55using System.Linq; 
    66using System.Text; 
     7using CastleMaster.Units; 
     8using CastleMaster.Ai.AIStates; 
     9using Microsoft.Xna.Framework; 
     10using CastleMaster.Units.Mobs; 
    711 
    812namespace CastleMaster.Players 
     
    1014    public class PlayerAI : Player 
    1115    { 
     16        public const int DIFFICULTY_EASY = 60 * 10; 
     17        public const int DIFFICULTY_NORMAL = 60 * 8; 
     18        public const int DIFFICULTY_HARD = 60 * 3; 
    1219 
    13         public PlayerAI(Team team, Level level, Camera camera) 
     20        private List<AIState> availableStates; 
     21        private TimerHelper brainTimer; 
     22        private AIState currentBrain; 
     23        private Player enemy; 
     24        private List<Type> unitTypes; 
     25 
     26        public PlayerAI(Team team, Level level, Camera camera, int difficuly, Player enemyPlayer) 
    1427            : base(team, level, camera) 
    1528        { 
     29            enemy = enemyPlayer; 
     30            availableStates = new List<AIState>(); 
     31            availableStates.Add(new IdleState(this)); 
     32            availableStates.Add(new AgressiveState(this)); 
     33            availableStates.Add(new DefensiveState(this)); 
     34            availableStates.Add(new CollectiveState(this)); 
     35 
     36            unitTypes = new List<Type>(); 
     37            unitTypes.Add(typeof(MobRanger)); 
     38            unitTypes.Add(typeof(MobWarrior)); 
     39 
     40            currentBrain = availableStates[0]; 
     41            brainTimer = new TimerHelper(difficuly, 1).Start(); 
     42            brainTimer.RoundEnded += ReThinkBestState; 
    1643        } 
    1744 
    18         public override Units.Unit SelectUnit(Team team) 
     45        public Point DefencePoint { get; set; } 
     46 
     47        public List<Type> AttackerTypes { get { return unitTypes; } } 
     48 
     49        public Player Enemy { get { return enemy;} } 
     50 
     51        public Point ForestPoint { get; set; } 
     52 
     53        public override void OnLevelLoaded() 
    1954        { 
     55            ReThinkBestState(); 
     56        } 
     57 
     58        private void ReThinkBestState() 
     59        { 
     60             
     61 
     62            AIState newState = null; 
     63            int importance = -1; 
     64            foreach (AIState aiState in availableStates) 
     65            { 
     66                int stateImportance = aiState.Importance; 
     67                if (importance == -1 || stateImportance > importance) 
     68                { 
     69                    importance = stateImportance; 
     70                    newState = aiState; 
     71                } 
     72            } 
     73            if (newState != currentBrain) 
     74            { 
     75                if (currentBrain != null) currentBrain.OnStateChange(); 
     76                currentBrain = newState; 
     77                currentBrain.OnStateChosen(); 
     78                Console.WriteLine("New state:" + currentBrain); 
     79            } 
     80        } 
     81 
     82        public override void Update() 
     83        { 
     84            brainTimer.UpdateStep(); 
     85            if (currentBrain != null) currentBrain.ApplyState(); 
     86        } 
     87 
     88        public override Unit SelectUnit(Team team) 
     89        { 
     90            if (currentBrain != null) 
     91                return currentBrain.SelectUnit(team); 
    2092            return null; 
    2193        } 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/Mob.cs

    r4646 r4671  
    2121        protected AStar pathFinder; 
    2222        protected int dirID; 
    23         protected AnimationHelper walkingAnimation; 
     23        protected TimerHelper walkingAnimation; 
    2424        protected float pushResistance; 
    2525        protected bool canBePushed; 
     
    3232            currentOrder = new Order(); 
    3333            pathFinder = new AStar(level, this); 
    34             walkingAnimation = new AnimationHelper(10, 2).Start(); 
     34            walkingAnimation = new TimerHelper(10, 2).Start(); 
    3535            immunityTime = 20; 
    3636            canBePushed = true; 
    3737            pushResistance = 0.0F; 
    3838        } 
     39 
     40        public bool HasActiveOrders { get { return currentOrder != null && !(currentOrder is OrderIdle) && !currentOrder.Finished; } } 
    3941 
    4042        public Level Level { get { return level; } } 
     
    7173        } 
    7274 
    73         public void OnGroupOrder(List<Mob> mobs, float x, float z) 
     75        public void OnGroupOrder<T>(List<T> mobs, float x, float z) where T : Mob 
    7476        { 
    7577            foreach (var mobGroup in mobs.GroupBy(m => m.TypeID)) 
    7678            { 
    77                 List<Mob> ms = mobGroup.ToList(); 
     79                List<T> ms = mobGroup.ToList(); 
    7880                ms[0].OnSameTypeGroupOrder(ms, x, z); 
    7981            } 
    8082        } 
    8183 
    82         protected virtual void OnSameTypeGroupOrder(List<Mob> mobs, float x, float z) 
     84        protected virtual void OnSameTypeGroupOrder<T>(List<T> mobs, float x, float z) where T : Mob 
    8385        { 
    8486            OnFunctionClick(x, z, mobs.Count, false); 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobRanger.cs

    r4646 r4671  
    2323        private bool isAttacking = false; 
    2424        private int maxDamage = 4; 
    25         private AnimationHelper hitAnimation; 
     25        private TimerHelper hitAnimation; 
    2626        private int spriteX; 
    2727        private float pushPower = 2.0F; 
     
    4545            isSolid = true; 
    4646            moveSpeed = 1.6F; 
    47             hitAnimation = new AnimationHelper(5, 5, false, 3); 
     47            hitAnimation = new TimerHelper(5, 5, false, 3); 
    4848            hitAnimation.RoundEnded += delegate() 
    4949            { 
     
    7878        } 
    7979 
    80         private void CreateAttackOrder(Unit u, int orderAmount, bool wasCalledBefore) 
     80        public void CreateAttackOrder(Unit u, int orderAmount, bool wasCalledBefore) 
    8181        { 
    8282            currentOrderType = OrderType.ATTACK; 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobWarrior.cs

    r4646 r4671  
    2222        private OrderType currentOrderType = OrderType.NONE; 
    2323        private bool isAttacking = false; 
    24         private int maxDamage = 7; 
    25         private AnimationHelper hitAnimation; 
     24        private int maxDamage = 6; 
     25        private TimerHelper hitAnimation; 
    2626        private int spriteX; 
    2727        private float pushPower = 5.0F; 
     
    4545            isSolid = true; 
    4646            moveSpeed = 1.25F; 
    47             hitAnimation = new AnimationHelper(8, 5, false, 3); 
     47            hitAnimation = new TimerHelper(8, 5, false, 3); 
    4848            hitAnimation.RoundEnded += delegate 
    4949            { 
     
    7979        } 
    8080 
    81         private void CreateAttackOrder(Unit u, int orderAmount, bool wasCalledBefore) 
     81        public void CreateAttackOrder(Unit u, int orderAmount, bool wasCalledBefore) 
    8282        { 
    8383            currentOrderType = OrderType.ATTACK; 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobWoodcutter.cs

    r4646 r4671  
    1010using CastleMaster.Entities.TileEntities; 
    1111using CastleMaster.Ai.Orders; 
     12using System.Diagnostics; 
    1213 
    1314namespace CastleMaster.Units.Mobs 
     
    1920        private TileEntityTree currentTarget; 
    2021        private bool isChopping = false; 
    21         private AnimationHelper choppingAnimation; 
     22        private TimerHelper choppingAnimation; 
    2223        private int currentSpriteX; 
    2324        private OrderType currentOrderType = OrderType.NONE; 
    2425        private int lastSameOrderAmount = 0; 
    25         private bool engangeChopping = false; 
    2626 
    2727        public MobWoodcutter(Level level, Player owner) 
     
    4242 
    4343            moveSpeed = 2.0F; 
    44             choppingAnimation = new AnimationHelper(10, 5, false, 3); 
     44            choppingAnimation = new TimerHelper(10, 5, false, 3); 
    4545            choppingAnimation.RoundEnded += delegate() 
    4646            { 
     47                owner.LumberAmount++; 
    4748                currentTarget.AvaliableLogs--; 
    4849                if (currentTarget.AvaliableLogs <= 0) 
    4950                { 
    50                     StopChopping(); 
    5151                    currentTarget.Remove(); 
    5252                    currentTarget = null; 
     53                    OrderChop(level.GetNearestEntity<TileEntityTree>(this, 5), 1, false); 
    5354                } 
    5455            }; 
     
    5859        { 
    5960            get { return 0; } 
     61        } 
     62 
     63        public void OrderChop(TileEntityTree te, int sameAmount, bool wasCalledBefore) 
     64        { 
     65            if (te == null) 
     66                return; 
     67            isChopping = true; 
     68            currentOrderType = OrderType.CHOP; 
     69            currentTarget = te; 
     70            SetOrder(new OrderMove(currentTarget.X, currentTarget.Z, 20.0F, sameAmount * 4.0F, true, !wasCalledBefore)); 
    6071        } 
    6172 
     
    8091            { 
    8192                if (currentTarget != null) StopChopping(); 
    82                 currentOrderType = OrderType.CHOP; 
    83                 currentTarget = (TileEntityTree)te; 
    84                 SetOrder(new OrderMove(currentTarget.X, currentTarget.Z, 20.0F, sameOrderAmount * 4.0F, true, !wasCalledBefore)); 
     93                OrderChop((TileEntityTree)te, sameOrderAmount, wasCalledBefore); 
    8594            } 
    8695            else 
     
    91100                    currentTarget = null; 
    92101                } 
    93                 SetOrder(new OrderMove(x, z, createNewPathFinder: !wasCalledBefore, stopOnMoveFail: true)); 
     102                SetOrder(new OrderMove(x, z, 2.0F, sameOrderAmount * 4.0F, createNewPathFinder: !wasCalledBefore, stopOnMoveFail: true)); 
    94103            } 
    95104            lastSameOrderAmount = sameOrderAmount; 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Unit.cs

    r4646 r4671  
    4141            immunityTime = 0; 
    4242        } 
     43 
     44        public int MaxHealth { get { return maxHealth; } } 
    4345 
    4446        public int Health { get; protected set; } 
     
    121123        } 
    122124 
    123         public float DistanceTo(float x, float z) 
    124         { 
    125             float xd = X - x; 
    126             float zd = Z - z; 
    127  
    128             return (float)(Math.Sqrt(xd * xd + zd * zd)); 
    129         } 
    130  
    131         public float DistanceToSqr(float x, float z) 
    132         { 
    133             float xd = X - x; 
    134             float zd = Z - z; 
    135  
    136             return xd * xd + zd * zd; 
    137         } 
    138  
    139125        public float DistanceFromScreenSpaceSqr(float x, float y) 
    140126        { 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/UnitKing.cs

    r4646 r4671  
    1111    public class UnitKing : Unit 
    1212    { 
     13        private bool isDestroyed = false; 
     14        private int timesHit = 0; 
     15         
    1316        public UnitKing(Level level, Player owner) 
    1417            : base(level, owner) 
     
    1720            depth = 5 * Viewport.TILESIZE; 
    1821            HasHealth = true; 
    19             maxHealth = 150; 
     22            maxHealth = 500; 
    2023 
    2124            isSolid = true; 
     
    3235            rectOffset.Update(-2 * Viewport.TILESIZE, -2 * Viewport.TILESIZE, 2 * Viewport.TILESIZE, 2 * Viewport.TILESIZE); 
    3336            immunityTime = 20; 
     37        } 
     38 
     39        public int TimesHit { get { return timesHit; } } 
     40 
     41        public bool IsDestroyed { get { return isDestroyed; } } 
     42 
     43        public override void Damage(Unit attacker, int damage, float dir, float pushPower) 
     44        { 
     45            base.Damage(attacker, damage, dir, pushPower); 
     46            timesHit++; 
    3447        } 
    3548 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/UnitStore.cs

    r4635 r4671  
    66using CastleMaster.World; 
    77using CastleMaster.Graphics; 
     8using CastleMaster.Units.Mobs; 
    89 
    910namespace CastleMaster.Units 
     
    1112    public class UnitStore : Unit 
    1213    { 
     14        public const int PRICE_WOODCUTTER = 10; 
     15        public const int PRICE_WARRIOR = 20; 
     16        public const int PRICE_RANGER = 10; 
     17        private Dictionary<Type, int> prices; 
     18        private bool isDestroyed = false; 
     19 
    1320        public UnitStore(Level level, Player owner) 
    1421            : base(level, owner) 
     
    1724            depth = 8 * Viewport.TILESIZE; 
    1825            HasHealth = true; 
    19             maxHealth = 100; 
     26            maxHealth = 200; 
    2027            immunityTime = 20; 
    2128 
     
    3239 
    3340            rectOffset.Update(-4 * Viewport.TILESIZE, -4 * Viewport.TILESIZE, 4 * Viewport.TILESIZE, 4 * Viewport.TILESIZE); 
     41 
     42            prices = new Dictionary<Type, int>(); 
     43            prices.Add(typeof(MobWoodcutter), PRICE_WOODCUTTER); 
     44            prices.Add(typeof(MobWarrior), PRICE_WARRIOR); 
     45            prices.Add(typeof(MobRanger), PRICE_RANGER); 
    3446        } 
     47 
     48        public T BuyUnit<T>(Type toBuy = null) where T : Mob 
     49        { 
     50            Type unitType = toBuy == null ? typeof(T) : toBuy; 
     51            int cost = prices[unitType]; 
     52            if (Owner.CoinsAmount - cost < 0) return null; 
     53            T m = (T)Activator.CreateInstance(unitType, level, Owner); 
     54            Owner.CoinsAmount -= cost; 
     55            return m; 
     56        } 
     57 
     58        public bool IsDestroyed { get { return isDestroyed; } } 
    3559 
    3660        public override void OnRemoved() 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Level.cs

    r4646 r4671  
    6262        protected Texture2D tileMap; 
    6363        private EntityComprarer comparer = new EntityComprarer(); 
    64         private AnimationHelper waterAnimation = new AnimationHelper(10, 2).Start(); 
     64        private TimerHelper waterAnimation = new TimerHelper(10, 2).Start(); 
    6565        private Player[] players; 
    6666 
     
    8888        } 
    8989 
     90        public List<Unit>[] Units { get { return units; } } 
     91 
    9092        public Player[] Players { get { return players; } } 
     93 
     94        public int[] Tiles { get { return tiles; } } 
    9195 
    9296        public int Width { get { return width; } } 
     
    470474            } 
    471475 
    472  
    473             //for (int z = zTile - 1; z <= zTile + 1; z++) 
    474             //{ 
    475             //    if (z < 0 || z >= height) continue; 
    476             //    for (int x = xTile - 1; x <= xTile + 1; x++) 
    477             //    { 
    478             //        if (x < 0 || x >= width) continue; 
    479             //        if (x == xTile && z == zTile) continue; 
    480  
    481             //        tp = x + z * width; 
    482             //        Tile t = registeredTiles[tiles[tp]]; 
    483             //        if (t.ID == TILE_VOID || t.IsSolidTo(ent)) blocks |= true; 
    484  
    485             //        List<Entity> ents = entitiesInTiles[tp]; 
    486  
    487             //        foreach (Entity e in ents) 
    488             //        { 
    489             //            if (e != ent) 
    490             //                blocks |= e.Blocks(ent); 
    491             //        } 
    492             //        if (!blocks) return tp; 
    493             //    } 
    494             //} 
    495  
    496476            return -1; 
     477        } 
     478 
     479        public T GetNearestEntity<T>(Entity caller, int radius) where T : Entity 
     480        { 
     481            T nearest = null; 
     482            float nearestDist = 0.0F, currentDist = 0.0F; 
     483 
     484            int xTile = (int)(caller.X / Viewport.TILESIZE); 
     485            int zTile = (int)(caller.Z / Viewport.TILESIZE); 
     486 
     487            List<T> inRadius = new List<T>(); 
     488            for (int z = zTile - radius; z <= zTile + radius; z++) 
     489            { 
     490                if (z < 0 || z >= height) continue; 
     491                for (int x = xTile - radius; x <= xTile + radius; x++) 
     492                { 
     493                    if (x < 0 || x >= width) continue; 
     494                    if (x == xTile && z == zTile) continue; 
     495 
     496                    entitiesInTiles[x + z * width].ForEach(delegate(Entity ent) 
     497                    { 
     498                        if (typeof(T).IsAssignableFrom(ent.GetType())) inRadius.Add((T)ent); 
     499                    }); 
     500                } 
     501            } 
     502 
     503            foreach (T ent in inRadius) 
     504            { 
     505                currentDist = ent.DistanceToSqr(caller.X, caller.Z); 
     506                if (nearest == null || currentDist < nearestDist) 
     507                { 
     508                    nearest = ent; 
     509                    nearestDist = currentDist; 
     510                } 
     511            } 
     512 
     513            return nearest; 
     514        } 
     515 
     516        public bool SolidTo(Entity ent, int xTile, int zTile) 
     517        { 
     518            if (registeredTiles[tiles[xTile + zTile * width]].IsSolidTo(ent)) 
     519                return true; 
     520 
     521            foreach (Entity e in entitiesInTiles[xTile + zTile * width]) 
     522                if (e.Blocks(ent)) return true; 
     523 
     524            return false; 
    497525        } 
    498526 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/LevelForest.cs

    r4635 r4671  
    66using CastleMaster.Units.Mobs; 
    77using Viewport = CastleMaster.Graphics.Viewport; 
     8using Microsoft.Xna.Framework; 
     9using CastleMaster.Players; 
    810 
    911namespace CastleMaster.World 
     
    1214    { 
    1315        private int TILE_FLOOR, TILE_WATER, TILE_FLOOR_SOLID, TILE_KING1_HINT, TILE_KING1_HINT2, TILE_STORE1_HINT, TILE_KING2_HINT, TILE_KING2_HINT2, TILE_STORE2_HINT; 
    14         private UnitKing king1, king2; 
    15         private UnitStore store1, store2; 
    16  
     16         
    1717        public LevelForest(Texture2D tileMap) 
    1818            : base(tileMap) 
     
    2222        protected override void InitTiles() 
    2323        { 
    24             king1 = new UnitKing(this, Players[0]); 
    25             store1 = new UnitStore(this, Players[0]); 
    26  
    27             king2 = new UnitKing(this, Players[1]); 
    28             store2 = new UnitStore(this, Players[1]); 
    29  
    3024            TILE_FLOOR = new TileFloor(this).ID; 
    3125            TILE_WATER = new TileWater(this).ID; 
    3226            TILE_FLOOR_SOLID = new TileFloor(this, true).ID; 
    33             TILE_KING1_HINT = new TileRenderHint(this, king1, true, false).ID; 
    34             TILE_KING1_HINT2 = new TileRenderHint(this, king1, false, false).ID; 
    35             TILE_STORE1_HINT = new TileRenderHint(this, store1, true, true).ID; 
    36             TILE_KING2_HINT = new TileRenderHint(this, king2, true, false).ID; 
    37             TILE_STORE2_HINT = new TileRenderHint(this, store2, true, true).ID; 
    38             TILE_KING2_HINT2 = new TileRenderHint(this, king2, false, false).ID; 
     27            TILE_KING1_HINT = new TileRenderHint(this, Players[0].King, true, false).ID; 
     28            TILE_KING1_HINT2 = new TileRenderHint(this, Players[0].King, false, false).ID; 
     29            TILE_STORE1_HINT = new TileRenderHint(this, Players[0].Store, true, true).ID; 
     30            TILE_KING2_HINT = new TileRenderHint(this, Players[1].King, true, false).ID; 
     31            TILE_STORE2_HINT = new TileRenderHint(this, Players[1].Store, true, true).ID; 
     32            TILE_KING2_HINT2 = new TileRenderHint(this, Players[1].King, false, false).ID; 
    3933        } 
    4034 
     
    5852            lb.AddTile(0xFF303030, TILE_FLOOR, 2); 
    5953 
     54            lb.AddTile(0xFF00FF00, TILE_FLOOR); 
     55            lb.AddTile(0xFF00FF01, TILE_FLOOR); 
     56            lb.AddTile(0xFF00FF10, TILE_FLOOR); 
     57            lb.AddTile(0xFF00FF20, TILE_FLOOR); 
     58            lb.AddTile(0xFF00FF30, TILE_FLOOR); 
     59            lb.AddTile(0xFF00FF40, TILE_FLOOR); 
     60            lb.AddTile(0xFF00FF11, TILE_FLOOR); 
     61            lb.AddTile(0xFF00FF21, TILE_FLOOR); 
     62            lb.AddTile(0xFF00FF31, TILE_FLOOR); 
     63            lb.AddTile(0xFF00FF50, TILE_FLOOR); 
     64 
     65            lb.AddTile(0xFF00FFFF, TILE_FLOOR); 
    6066            lb.AddTile(0xFF0000FF, TILE_FLOOR); 
    6167            lb.AddTile(0xFFFFD800, TILE_FLOOR); 
     
    6672            lb.AddEntity(0xFF00CC00, typeof(TileEntityBlock), 8.0F, 8.0F, this, 1, 2); 
    6773            lb.AddEntity(0xFF00E500, typeof(TileEntityBlock), 8.0F, 8.0F, this, 0, 2); 
    68             lb.AddEntity(0xFF00FF00, typeof(TileEntityBlock), 8.0F, 8.0F, this, 6, 0); 
    6974            lb.AddEntity(0xFF0000FF, typeof(MobWarrior), 8.0F, 8.0F, this, Players[0]); 
    7075            lb.AddEntity(0xFFFF0000, typeof(MobWoodcutter), 8.0F, 8.0F, this, Players[0]); 
     
    7378            lb.AddEntity(0xFF00FFFF, typeof(MobWoodcutter), 8.0F, 8.0F, this, Players[1]); 
    7479 
     80            lb.AddCustom(0xFF00FF00, delegate(Level level, int xTile, int zTile) 
     81            { 
     82                Players[1].HomePoint = new Point(xTile, zTile); 
     83            }); 
     84 
     85            lb.AddCustom(0xFF00FF20, delegate(Level level, int xTile, int zTile) 
     86            { 
     87                Players[1].WoodcutterSpawnPoint = new Point(xTile, zTile); 
     88            }); 
     89 
     90            lb.AddCustom(0xFF00FF30, delegate(Level level, int xTile, int zTile) 
     91            { 
     92                Players[1].WarriorSpawnPoint = new Point(xTile, zTile); 
     93            }); 
     94 
     95            lb.AddCustom(0xFF00FF40, delegate(Level level, int xTile, int zTile) 
     96            { 
     97                Players[1].RangerSpawnPoint = new Point(xTile, zTile); 
     98            }); 
     99 
     100            lb.AddCustom(0xFF00FF10, delegate(Level level, int xTile, int zTile) 
     101            { 
     102                ((PlayerAI)Players[1]).ForestPoint = new Point(xTile, zTile); 
     103            }); 
     104 
     105            lb.AddCustom(0xFF00FF50, delegate(Level level, int xTile, int zTile) 
     106            { 
     107                ((PlayerAI)Players[1]).DefencePoint = new Point(xTile, zTile); 
     108            }); 
     109 
     110            lb.AddCustom(0xFF00FF01, delegate(Level level, int xTile, int zTile) 
     111            { 
     112                Players[0].HomePoint = new Point(xTile, zTile); 
     113            }); 
     114 
     115            lb.AddCustom(0xFF00FF11, delegate(Level level, int xTile, int zTile) 
     116            { 
     117                Players[0].WoodcutterSpawnPoint = new Point(xTile, zTile); 
     118            }); 
     119 
     120            lb.AddCustom(0xFF00FF21, delegate(Level level, int xTile, int zTile) 
     121            { 
     122                Players[0].WarriorSpawnPoint = new Point(xTile, zTile); 
     123            }); 
     124 
     125            lb.AddCustom(0xFF00FF31, delegate(Level level, int xTile, int zTile) 
     126            { 
     127                Players[0].RangerSpawnPoint = new Point(xTile, zTile); 
     128            }); 
     129 
    75130            lb.AddCustom(0xFFFF6A03, delegate(Level level, int xTile, int zTile) 
    76131            { 
    77                 level.AddEntity(king2, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
     132                level.AddEntity(Players[1].King, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
    78133            }); 
    79134            lb.AddCustom(0xFFFF6A02, delegate(Level level, int xTile, int zTile) 
    80135            { 
    81                 level.AddEntity(store2, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
     136                level.AddEntity(Players[1].Store, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
    82137            }); 
    83138 
    84139            lb.AddCustom(0xFFFF6A00, delegate(Level level, int xTile, int zTile) 
    85140            { 
    86                 level.AddEntity(king1, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
     141                level.AddEntity(Players[0].King, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
    87142            }); 
    88143            lb.AddCustom(0xFFFF6A01, delegate(Level level, int xTile, int zTile) 
    89144            { 
    90                 level.AddEntity(store1, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
     145                level.AddEntity(Players[0].Store, xTile * Viewport.TILESIZE + 8.0F, zTile * Viewport.TILESIZE + 8.0F); 
    91146            }); 
    92147 
Note: See TracChangeset for help on using the changeset viewer.