예제 #1
0
        public override void Act(KeyboardState ks, MouseState ms)
        {
            Vector3 mousePoint = GetMouseIntersectionPoint(ms, Plane.Z);

            TurnTowardsXY(mousePoint);

            if (ks[Key.A] && Position.X > -17)
            {
                MoveOffset(-_movementSpeed * KWEngine.DeltaTimeFactor, 0, 0);
            }
            if (ks[Key.D] && Position.X < 17)
            {
                MoveOffset(+_movementSpeed * KWEngine.DeltaTimeFactor, 0, 0);
            }
            if (ks[Key.W] && Position.Y < 10)
            {
                MoveOffset(0, +_movementSpeed * KWEngine.DeltaTimeFactor, 0);
            }
            if (ks[Key.S] && Position.Y > -10)
            {
                MoveOffset(0, -_movementSpeed * KWEngine.DeltaTimeFactor, 0);
            }

            if (ms.LeftButton == ButtonState.Pressed || ks[Key.Space])
            {
                long timestampNow = GetCurrentTimeInMilliseconds();

                if (timestampNow - _timestampLastShot > _cooldown)
                {
                    Vector3 lav = GetLookAtVector();

                    Shot s = new Shot(this);
                    s.SetModel("KWCube");
                    s.Name = "PlayerShot";
                    s.SetRotation(this.Rotation);
                    s.SetPosition(this.Position + lav);
                    s.SetScale(0.075f, 0.075f, 0.5f);
                    s.IsCollisionObject = true;
                    s.SetGlow(0, 1, 0, 1);
                    CurrentWorld.AddGameObject(s);

                    _timestampLastShot = timestampNow;
                }
            }

            Intersection i = GetIntersection(0, 0, 0, typeof(Enemy));

            if (i != null)
            {
                CurrentWorld.RemoveGameObject(this);
                Explosion ex = new Explosion(Position, 512, 5, ExplosionType.SkullRingZ);
                CurrentWorld.AddGameObject(ex);
            }
        }
예제 #2
0
        public GameSession()
        {
            //---Player Info---
            CurrentPlayer = new Player {
                Name = "Patrick", CharacterClass = "Fighter", HitPoints = 10, Gold = 100, ExperiencePoints = 0, Level = 1
            };

            //---Location Info---
            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #3
0
 public void MoveWest()
 {
     if (CurrentWorld.LocationAt(CurrentLocation.XCoordinate - 1, CurrentLocation.YCoordinate) != null)
     {
         CurrentLocation = CurrentWorld.LocationAt(CurrentLocation.XCoordinate - 1, CurrentLocation.YCoordinate);
         if (CurrentLocation.IsCheckpoint)
         {
             Checkpoint = CurrentLocation;
         }
     }
 }
예제 #4
0
        public override void Act(KeyboardState ks, MouseState ms)
        {
            if (!IsInsideScreenSpace)
            {
                CurrentWorld.RemoveGameObject(this);
                return;
            }

            Move(_movementSpeed * KWEngine.DeltaTimeFactor);

            Intersection intersection;

            if (_parent is Player)
            {
                intersection = GetIntersection(0, 0, 0, typeof(Enemy));
            }
            else
            {
                intersection = GetIntersection(0, 0, 0, typeof(Player));
            }

            if (intersection != null && !intersection.Object.Equals(_parent))
            {
                if (_parent is Player)
                {
                    if (intersection.Object is Enemy)
                    {
                        ((Enemy)intersection.Object).ReduceHealth(100);
                        CurrentWorld.RemoveGameObject(this);
                        Explosion ex = new Explosion(Position, 16);
                        ex.SetColor(1, 1, 1);
                        ex.SetGlow(1, 1, 0.5f, 0.25f);
                        CurrentWorld.AddGameObject(ex);
                    }
                }
                else if (_parent is Enemy)
                {
                    if (intersection.Object is Player)
                    {
                        CurrentWorld.RemoveGameObject(intersection.Object);
                        Explosion ex1 = new Explosion(intersection.Object.Position, 128);
                        ex1.SetColor(0, 1, 0);
                        ex1.SetGlow(0, 1, 0.5f, 1);
                        CurrentWorld.AddGameObject(ex1);

                        CurrentWorld.RemoveGameObject(this);
                        Explosion ex = new Explosion(Position, 16);
                        ex.SetColor(1, 1, 1);
                        ex.SetGlow(1, 1, 0.5f, 0.25f);
                        CurrentWorld.AddGameObject(ex);
                    }
                }
            }
        }
예제 #5
0
 public void SaveWorld(string worldName)
 {
     if (WorldExists(worldName))
     {
         CurrentWorld.Save(worldName);
     }
     else
     {
         CurrentWorld = CreateWorld(worldName);
     }
 }
예제 #6
0
 public void MoveNorth()
 {
     if (CurrentWorld.LocationAt(CurrentLocation.XCoordinate, CurrentLocation.YCoordinate + 1) != null)
     {
         CurrentLocation = CurrentWorld.LocationAt(CurrentLocation.XCoordinate, CurrentLocation.YCoordinate + 1);
         if (CurrentLocation.IsCheckpoint)
         {
             Checkpoint = CurrentLocation;
         }
     }
 }
예제 #7
0
 public void StationClicked(Station clickedStation)
 {
     if (CurrentStation == null)
     {
         CurrentStation = clickedStation;
     }
     else
     {
         CurrentWorld.AddWay("k", 1, CurrentStation, clickedStation);
         CurrentStation = null;
     }
 }
예제 #8
0
    public virtual void Die(bool byAge)
    {
        IsAlive = false;

        CurrentWorld.EntityDie(this, byAge);

        ParticleSystem particles = Instantiate(DeathParticles, this.transform.position, Quaternion.identity);

        Destroy(particles.gameObject, particles.main.duration);

        Destroy();
    }
예제 #9
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            var transformMatrix = MainCamera.GetViewMatrix();

            SpriteBatch.Begin(transformMatrix: transformMatrix);
            CurrentWorld.Draw();
            SpriteBatch.End();

            base.Draw(gameTime);
        }
예제 #10
0
파일: Enemy.cs 프로젝트: vardrop/KWEngine2
        public override void Act(KeyboardState ks, MouseState ms, float deltaTimeFactor)
        {
            if (_health <= 0)
            {
                Explosion ex = new Explosion(Position, 16);
                ex.SetColor(1, 1, 1);
                ex.SetGlow(1, 0, 1f, 0.5f);
                CurrentWorld.AddGameObject(ex);

                CurrentWorld.RemoveGameObject(this);
            }
        }
예제 #11
0
        public GameSession(string characterName)
        {
            CurrentPlayer = new Player(characterName, "Hardcoded", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld    = WorldFactory.CreateWorld();    // Stvori world
            CurrentLocation = CurrentWorld.LocationAt(0, 0); // Trenutna lokacija
        }
예제 #12
0
        public GameSession()
        {
            CurrentPlayer = new Player("Auston", "Fighter", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #13
0
        public GameSession()
        {
            CurrentPlayer = new Player("Chuyue", "Fighter", 0, 10, 10, 1000000);

            //Player should always have something to fight with
            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #14
0
    protected virtual float GiveBirthAction()
    {
        IsPregnant           = false;
        LastReproductionTime = SecondsAlive;

        Entity child = Instantiate(this, transform.parent);

        PreviousCell.TrySetContent(child);
        child.Initialize(CurrentWorld, PreviousCell, ChildNormalMoveSeconds, ChildFastMoveDivisor);
        CurrentWorld.NewEntity(child);

        return(GiveBirthCost);
    }
예제 #15
0
        public GameSession()
        {
            CurrentPlayer = new Player("Vincent", "Azure Administrator", 0, 10, 10, 0, 0);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
예제 #16
0
        public GameSession()
        {
            CurrentPlayer = new Player(name: "Tahj", characterClass: "Fighter", experiencePoints: 0, maximumHitPoints: 10,
                                       currentHitPoints: 10, strength: 10, dexterity: 10, armorClass: 10, strengthAbilityScore: 0, gold: 10);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #17
0
        public void StartTheGame()
        {
            CurrentPlayer = new Player("John Doe", "Scientist", 0, 10, 10, 10, 100);

            if (CurrentPlayer.Inventory.Weapons.Count == 0)
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateItem(1));
            }
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateItem(6));
            CurrentPlayer.LearnScheme(SchemeFactory.GetSchemeById(1));

            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #18
0
 private void AppleFloorContacted(object sender, CollideEventArg collide)
 {
     if (collide.Dictionary.ContainsKey(BodyId) && collide.Dictionary[BodyId].Contains(_floor))
     {
         Body.Restitution = 0f;
         _isFalling       = false;
         CurrentWorld.RemoveBody(_floor);
         Body.CollisionCategories = Category.All & ~Category.Cat10;
         Body.CollidesWith        = Category.All & ~Category.Cat10;
         _tree.Apple = null;
         CurrentWorld.AddDynamicEntity(this);
         CanInteract = true;
     }
 }
예제 #19
0
        public void MonsterAttackDamageCalculation()
        {
            int damageDealtToPlayer = RandomNumberGenerator.NumberBetween
                                          (CurrentMonster.MinimumDamage, CurrentMonster.MaximumDamage) +
                                      StatisticsCalculator.AbilityScoreCalculator(CurrentMonster.Strength);
            MonsterAttackSuccessNotification(damageDealtToPlayer);

            CurrentPlayer.TakeDamage(damageDealtToPlayer);

            if (CurrentPlayer.IsDead)
            {
                CurrentLocation = CurrentWorld.LocationAt(0, -1);
                CurrentPlayer.CompletelyHeal();
            }
        }
예제 #20
0
        public GameSession()
        {
            CurrentPlayer = new Player {
                Name = "Ryan", CharacterClass = "Fighter", HitPoints = 10, Gold = 100000, ExperiencePoints = 0, Level = 1
            };

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
예제 #21
0
        public GameSession()
        {
            CurrentPlayer = new Player // object literal - improves readability
            {
                Name             = "Eli",
                CharacterClass   = "Monk",
                HitPoints        = 10,
                Gold             = 1000000,
                ExperiencePoints = 0,
                Level            = 1,
            };

            CurrentWorld    = WorldFactory.CreateWorld(); // we only use this once - so we make this static
            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
예제 #22
0
        public GameSession()
        {
            CurrentPlayer = new Player
            {
                Name             = "Joe",
                CharacterClass   = "Fighter",
                HitPoints        = 10,
                Gold             = 1000000,
                ExperiencePoints = 0,
                Level            = 1
            };

            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
예제 #23
0
        public override void UpdateMemoryBlocks()
        {
            DetectControlMode();
            VisualFOV.Dims   = new TensorDimensions(WidthFov, HeightFov * FloatsPerPixel);
            VisualFOF.Dims   = new TensorDimensions(WidthFof, HeightFof * FloatsPerPixel);
            Text.Count       = TextSize;
            Data.Count       = DataSize;
            DataLength.Count = 1;
            RewardMB.Count   = 1;
            LTStatus.Count   = LT_STATUS_COUNT;

            if (CurrentWorld != null)
            {
                CurrentWorld.UpdateMemoryBlocks();
            }
        }
예제 #24
0
        public GameSession()
        {
            CurrentPlayer = new Player("Scott", "Fighter", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }

            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(2001));
            CurrentPlayer.LearnRecipe(RecipeFactory.RecipeByID(1));

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #25
0
        public GameSession()
        {
            CurrentPlayer = new Player("SK", "Warrior", 0, 10, 10, 1000000);

            if (!CurrentPlayer.Weapons.Any())
            {
                CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(1001));
            }
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(2001));
            CurrentWorld    = WorldFactory.CreateWorld();
            CurrentLocation = CurrentWorld.LocationAt(0, -1);
            CurrentPlayer.LearnRecipe(RecipeFactory.GetRecipeByID(1));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3001));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3002));
            CurrentPlayer.AddItemToInventory(ItemFactory.CreateGameItem(3003));
        }
예제 #26
0
        public GameSession()
        {
            CurrentPlayer                  = new Player();
            CurrentPlayer.Name             = "Atlas";
            CurrentPlayer.Class            = "Dog";
            CurrentPlayer.HitPoints        = 10;
            CurrentPlayer.Gold             = 1000000;
            CurrentPlayer.ExperiencePoints = 0;
            CurrentPlayer.Level            = 1;

            WorldFactory factory = new WorldFactory();

            CurrentWorld = factory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #27
0
        public GameSession()
        {
            CurrentPlayer                  = new Player();
            CurrentPlayer.Name             = "Scott";
            CurrentPlayer.CharacterClass   = "Fighter";
            CurrentPlayer.HitPoints        = 10;
            CurrentPlayer.Gold             = 5;
            CurrentPlayer.ExperiencePoints = 0;
            CurrentPlayer.Level            = 1;

            WorldFactory factory = new WorldFactory();

            CurrentWorld = factory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, -1);
        }
예제 #28
0
        private void UpdateMap()
        {
            int xOffset = 2;
            int yOffset = 2;

            for (int i = 0; i < Map.Count; i++)
            {
                xOffset = 2;
                for (int j = 0; j < Map[i].Count; j++)
                {
                    Map[i][j] = CurrentWorld.LocationAt(CurrentLocation.XCoordinate - xOffset, CurrentLocation.YCoordinate + yOffset) ?? CurrentWorld.LocationAt(100, 100);
                    xOffset--;
                }
                yOffset--;
            }
        }
예제 #29
0
        public GameSession()
        {
            //default player class for testing
            CurrentPlayer = new Player
            {
                Name             = "Scott",
                CharacterClass   = "Fighter",
                HitPoints        = 10,
                Gold             = 1000000,
                ExperiencePoints = 0,
                Level            = 1
            };

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
        }
예제 #30
0
        public GameSession()
        {
            CurrentPlayer = new Player
            {
                Name             = "Richard",
                CharacterClass   = "Wizard",
                HitPoints        = 10,
                ExperiencePoints = 0,
                Level            = 1,
                Gold             = 10
            };

            CurrentWorld = WorldFactory.CreateWorld();

            CurrentLocation = CurrentWorld.LocationAt(0, 0);
            CurrentPlayer.Inventory.Add(ItemFactory.CreateItem(1001));
        }