コード例 #1
0
ファイル: Character.cs プロジェクト: sideroff/Game
        protected Character(
            string spriteTexturePath,
            string type,
            Vector2 position,
            int healthPoints,
            int attackPoints,
            int defencePoints,
            int range,
            int stepSize,
            int textureHeight,
            int textureWidth,
            AttackState attackState = AttackState.notactivated)
        {
            this.SpriteTexturePath = spriteTexturePath;
            this.Type                = type;
            this.Position            = position;
            this.HealthPoints        = healthPoints;
            this.initialHealthPoints = healthPoints;
            this.AttackPoints        = attackPoints;
            this.DefencePoints       = defencePoints;
            this.Range               = range;
            this.StepSize            = stepSize;
            this.TextureHeight       = textureHeight;
            this.TextureWidth        = textureWidth;
            this.Bounds              = new Rectangle((int)this.Position.X, (int)this.Position.Y, this.TextureWidth, this.TextureHeight);
            this.collisionHandler    = new NewCollisionHandler();
            this.AttackState         = attackState;


            this.FramesPerSecond = 5;
            this.IsMoving        = false;
            this.Animations      = new Dictionary <string, Rectangle[]>();

            PlayAnimation("idleDown");
        }
コード例 #2
0
        /// <summary>
        /// Published method, contacts all listeners
        /// </summary>
        /// <param name="entityKeys"></param>
        /// <param name="entityTags"></param>
        private void OnNewCollision(Guid[] entityKeys, string[] entityTags, IDictionary <Guid, IDictionary <Type, IComponent> > entityComponents)
        {
            // DECLARE and INSTANTIATE a new CollisionHandler, pass it 'entityKeys', 'entityTags' and 'entityComponents' and call it 'args'
            ICollisionInput args = new CollisionHandler(entityKeys, entityTags, entityComponents);

            // IF at least one collision listener is subscribed, publish collision event
            NewCollisionHandler?.Invoke(this, args);
        }
コード例 #3
0
 public Engine(IMap map, IMapFactory mapFactory, ITileFactory tileFactory)
 {
     this.graphics              = new GraphicsDeviceManager(this);
     this.collisionHandler      = new NewCollisionHandler();
     this.monsters              = new MonsterData();
     this.players               = new PlayerData();
     this.Content.RootDirectory = "Content";
     this.map         = map;
     this.MapFactory  = mapFactory;
     this.TileFactory = tileFactory;
 }