Changeset 4616 for 2013/30


Ignore:
Timestamp:
2013-07-24 11:17:16 (6 years ago)
Author:
dezhidki
Message:

Talletus.

Location:
2013/30/DenisZ/CastleMaster/CastleMaster
Files:
7 added
13 edited

Legend:

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

    r4592 r4616  
    7979    <Compile Include="Ai\Orders\OrderMove.cs" /> 
    8080    <Compile Include="Entities\Entity.cs" /> 
     81    <Compile Include="Entities\EntityArrow.cs" /> 
    8182    <Compile Include="Entities\TileEntities\TileEntity.cs" /> 
    8283    <Compile Include="Entities\TileEntities\TileEntityBlock.cs" /> 
     
    101102    <Compile Include="Game.cs" /> 
    102103    <Compile Include="Units\Mobs\Mob.cs" /> 
     104    <Compile Include="Units\Mobs\MobRanger.cs" /> 
    103105    <Compile Include="Units\Mobs\MobWarrior.cs" /> 
    104106    <Compile Include="Units\Mobs\MobWoodcutter.cs" /> 
    105107    <Compile Include="Units\Unit.cs" /> 
     108    <Compile Include="Units\UnitKing.cs" /> 
    106109    <Compile Include="World\Level.cs" /> 
    107110    <Compile Include="World\LevelBuilder.cs" /> 
    108     <Compile Include="World\LevelTest.cs" /> 
     111    <Compile Include="World\LevelForest.cs" /> 
     112    <Compile Include="World\Tiles\TileRenderHint.cs" /> 
    109113    <Compile Include="World\Tiles\Tile.cs" /> 
    110114    <Compile Include="World\Tiles\TileFloor.cs" /> 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Entities/Entity.cs

    r4592 r4616  
    2626            Removed = false; 
    2727            rectOffset = new BoundingRectangle(-width / 2, -depth / 2, width / 2, depth / 2, null); 
     28            IsRendering = false; 
    2829        } 
     30 
     31        public bool IsRendering { get; set; } 
    2932 
    3033        public bool Removed { get; protected set; } 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Game.cs

    r4592 r4616  
    3131        private RenderHelper renderer; 
    3232        private Camera camera; 
    33         private LevelTest level; 
     33        private LevelForest level; 
    3434        private Player[] players; 
    3535 
     
    6464            graphics.PreferredBackBufferWidth = WIDTH; 
    6565            graphics.PreferredBackBufferHeight = HEIGHT; 
    66             graphics.SynchronizeWithVerticalRetrace = false; 
     66            graphics.SynchronizeWithVerticalRetrace = true; 
    6767            graphics.ApplyChanges(); 
    6868            Window.Title = TITLE; 
     
    125125            base.BeginRun(); 
    126126 
    127             level = new LevelTest(Resources.LEVEL_TEST); 
     127            level = new LevelForest(Content.Load<Texture2D>("levels/levelForest")); 
    128128            camera = new Camera(level); 
    129129            AddPlayer(new PlayerReal(TEAM1, level, camera)); 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Graphics/Resources.cs

    r4592 r4616  
    88        public static int SPRITESHEET_TILES { get; private set; } 
    99        public static int SPRITESHEET_ICONS { get; private set; } 
    10         public static Texture2D LEVEL_TEST { get; private set; } 
    1110        public static int SPRITESHEET_WOODCUTTER { get; private set; } 
    1211        public static int SPRITESHEET_WARRIOR { get; private set; } 
     12        public static int SPRITESHEET_RANGER { get; private set; } 
     13        public static int SPRITE_KING { get; private set; } 
    1314 
    1415        public static void LoadResources(ContentManager cm, RenderHelper renderer) 
     
    1819            SPRITESHEET_WOODCUTTER = renderer.RegisterSpriteSheet(new SpriteSheet(cm.Load<Texture2D>("mobs/woodcutter"), 32, 32)); 
    1920            SPRITESHEET_WARRIOR = renderer.RegisterSpriteSheet(new SpriteSheet(cm.Load<Texture2D>("mobs/warrior"), 32, 32)); 
    20             LEVEL_TEST = cm.Load<Texture2D>("levels/levelTest"); 
     21            SPRITESHEET_RANGER = renderer.RegisterSpriteSheet(new SpriteSheet(cm.Load<Texture2D>("mobs/archer"), 32, 32)); 
     22            SPRITE_KING = renderer.RegisterSpriteSheet(new SpriteSheet(cm.Load<Texture2D>("mobs/king"), 160, 128)); 
    2123        } 
    2224    } 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/Mob.cs

    r4592 r4616  
    8585        } 
    8686 
    87         public override void OnDamage(Unit attacker, int damage, float dir, float pushPower) 
     87        public override void Damage(Unit attacker, int damage, float dir, float pushPower) 
    8888        { 
    89             base.OnDamage(attacker, damage, dir, pushPower); 
     89            base.Damage(attacker, damage, dir, pushPower); 
    9090            if (canBePushed) 
    9191                Push(dir, pushPower); 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobWarrior.cs

    r4592 r4616  
    1414    { 
    1515        private enum OrderType { ATTACK, WALK, NONE } 
     16 
     17        private const float ATTACK_RANGE = 20.0F; 
     18        private const float ATTACK_RANGE_SQR = ATTACK_RANGE * ATTACK_RANGE; 
    1619 
    1720        private Unit target; 
     
    7073        { 
    7174            currentOrderType = OrderType.ATTACK; 
    72             SetOrder(new OrderMove(u.X, u.Z, 20.0F, true)); 
     75            SetOrder(new OrderMove(u.X, u.Z, ATTACK_RANGE, true)); 
    7376            target = u; 
    7477        } 
    7578 
    76         public override void OnDamage(Unit attacker, int damage, float dir, float pushPower) 
     79        public override void Damage(Unit attacker, int damage, float dir, float pushPower) 
    7780        { 
    78             base.OnDamage(attacker, damage, dir, pushPower); 
     81            base.Damage(attacker, damage, dir, pushPower); 
    7982            if (!isAttacking && currentOrderType == OrderType.NONE) 
    8083                CreateAttackOrder(attacker); 
     
    9295        public override void OnFunctionClick(float x, float z) 
    9396        { 
    94             Unit u = Owner.SelectUnit(Game.TEAM2); 
     97            Unit u = Owner.SelectUnit(Game.GetEnemyTeam(Owner.Team)); 
    9598            if (u != null) 
    96             { 
    9799                CreateAttackOrder(u); 
    98             } 
    99100            else 
    100101            { 
     
    111112            if (isAttacking) 
    112113            { 
    113                 if (DistanceToSqr(target.X, target.Z) > 625.0F) 
     114                if (DistanceToSqr(target.X, target.Z) > ATTACK_RANGE_SQR) 
    114115                { 
    115116                    isAttacking = false; 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Mobs/MobWoodcutter.cs

    r4592 r4616  
    1717        private bool isChopping = false, isOrderedToChop = false; 
    1818        private AnimationHelper choppingAnimation; 
    19         private AnimationHelper choppingTimer; 
    2019        private int currentSpriteX; 
    2120 
     
    3837            moveSpeed = 1.0F; 
    3938            choppingAnimation = new AnimationHelper(10, 5, false, 3); 
    40             choppingTimer = new AnimationHelper(30, 1); 
    41             choppingTimer.RoundEnded += delegate() 
     39            choppingAnimation.RoundEnded += delegate() 
    4240            { 
    4341                currentTarget.AvaliableLogs--; 
     
    5452        { 
    5553            choppingAnimation.Start(); 
    56             choppingTimer.Start(); 
    5754            isChopping = true; 
    5855        } 
     
    6461            choppingAnimation.Stop(); 
    6562            choppingAnimation.Reset(); 
    66             choppingTimer.Stop(); 
    67             choppingTimer.Reset(); 
    6863        } 
    6964 
     
    10297            { 
    10398                choppingAnimation.UpdateStep(); 
    104                 choppingTimer.UpdateStep(); 
    10599            } 
    106100 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/Unit.cs

    r4592 r4616  
    6666        { 
    6767            if (u.CanBeHurtBy(this)) 
    68                 u.OnDamage(this, damage, dir, pushPower); 
    69             if (u.Health <= 0) 
    70                 u.Remove(); 
     68                u.Damage(this, damage, dir, pushPower); 
    7169        } 
    7270 
    73         public virtual void OnDamage(Unit attacker, int damage, float dir, float pushPower) 
     71        public virtual void Damage(Unit attacker, int damage, float dir, float pushPower) 
    7472        { 
    7573            Health -= damage; 
     
    8179                HasHealth = false; 
    8280            } 
     81            if (Health <= 0) 
     82                Remove(); 
    8383        } 
    8484 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Level.cs

    r4593 r4616  
    4848    { 
    4949        public const int TILE_VOID = 0; 
    50         public const int UPDATES_IN_TICK = 50; 
     50        public const int UPDATES_IN_TICK = 500; 
    5151        protected List<Tile> registeredTiles; 
    5252        protected int[] tiles; 
     
    7575            registeredTiles = new List<Tile>(); 
    7676 
    77             new Tile(this); 
    78             InitTiles(); 
    79  
    8077            units = new List<Unit>[2]; 
    8178            units[0] = new List<Unit>(); 
     
    10299        protected virtual void InitTiles() { } 
    103100 
    104         public virtual void InitLevel() { } 
     101        public virtual void InitLevel() 
     102        { 
     103            new Tile(this); 
     104            InitTiles(); 
     105        } 
    105106 
    106107        public void RenderBackground(Camera camera, RenderHelper renderer) 
     
    129130                        if (t.ID != TILE_VOID) 
    130131                            t.Render(renderer, this, new Vector2((x * Viewport.FLOOR_TILE_WIDTH + (y & 1) * Viewport.X_STEP) * Viewport.ZOOM, (y * Viewport.Y_STEP + Viewport.Y_STEP) * Viewport.ZOOM), xTile, zTile, data[tp]); 
    131                         entitiesInTiles[tp].ForEach(ent => entitesToRender.Add(ent)); 
     132                        entitiesInTiles[tp].ForEach(AddEntityToRenderList); 
    132133                    } 
    133134                } 
     
    137138        } 
    138139 
     140        public void AddEntityToRenderList(Entity ent) 
     141        { 
     142            if (!ent.IsRendering) entitesToRender.Add(ent); 
     143            ent.IsRendering = true; 
     144        } 
     145 
    139146        public void RenderEntities(Camera camera, RenderHelper renderer) 
    140147        { 
     
    146153 
    147154                foreach (Entity ent in entitesToRender) 
     155                { 
    148156                    ent.Render(renderer); 
     157                    ent.IsRendering = false; 
     158                } 
    149159 
    150160                renderer.SetOffset(); 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/World/Tiles/TileFloor.cs

    r4535 r4616  
    66    public class TileFloor : Tile 
    77    { 
    8         public TileFloor(Level level) 
     8        public TileFloor(Level level, bool isSolid = false) 
    99            : base(level) 
    1010        { 
     11            this.IsSolid = isSolid; 
    1112        } 
    1213 
  • 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMasterContent/CastleMasterContent.contentproj

    r4550 r4616  
    3131  </ItemGroup> 
    3232  <ItemGroup> 
    33     <Compile Include="levels\testLevel.png"> 
    34       <Name>testLevel</Name> 
    35       <Importer>TextureImporter</Importer> 
    36       <Processor>TextureProcessor</Processor> 
    37     </Compile> 
    3833    <Compile Include="misc\buildingmaterial.png"> 
    3934      <Name>buildingmaterial</Name> 
     
    138133  </ItemGroup> 
    139134  <ItemGroup> 
    140     <Compile Include="levels\levelTest.png"> 
    141       <Name>levelTest</Name> 
     135    <Compile Include="levels\levelForest.png"> 
     136      <Name>levelForest</Name> 
     137      <Importer>TextureImporter</Importer> 
     138      <Processor>TextureProcessor</Processor> 
     139    </Compile> 
     140  </ItemGroup> 
     141  <ItemGroup> 
     142    <Compile Include="mobs\king.png"> 
     143      <Name>king</Name> 
    142144      <Importer>TextureImporter</Importer> 
    143145      <Processor>TextureProcessor</Processor> 
Note: See TracChangeset for help on using the changeset viewer.