Esempio n. 1
0
        public GameHandler()
        {
            player = new Player(Game1.VIEW_WIDTH / 2, Game1.VIEW_HEIGHT / 2);
            enemy = new Enemy(Game1.VIEW_WIDTH / 2, Game1.VIEW_HEIGHT / 2);
            hud = new Hud();

            //rtCircles = new RenderTarget2D(Game1.graphicsDevice, Game1.VIEW_WIDTH, Game1.VIEW_HEIGHT, true, Game1.graphicsDevice.DisplayMode.Format, DepthFormat.Depth24, 1, RenderTargetUsage.PreserveContents);
            item = 0;
            lost = false;
            lostI = 300;
        }
        private Enemy CreateEnemyFromDef(EnemyDef definition)
        {
            Enemy enemy = new Enemy(_textureManager, _gameData);
            // enemy.SetPosition(definition.StartPosition);

            if (definition.EnemyType == "particlesMiddle")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(-1400, 0, 0));

                enemy.Path = new Path(_pathPoints, 60);
            }
            else if (definition.EnemyType == "particlesTop")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 200, 0));
                _pathPoints.Add(new Vector(-1400, 200, 0));

                    enemy.Path = new Path(_pathPoints, 60);

            }

            else if (definition.EnemyType == "particlesBottom")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, -200, 0));
                _pathPoints.Add(new Vector(-1400, -200, 0));

                enemy.Path = new Path(_pathPoints, 60);
            }

            else if (definition.EnemyType == "particlesBottomMid")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, -100, 0));
                _pathPoints.Add(new Vector(-1400, -100, 0));

                enemy.Path = new Path(_pathPoints, 100);
            }
            else if (definition.EnemyType =="particlesNewMiddle")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 0, 0));
                _pathPoints.Add(new Vector(500, 100, 0));
                _pathPoints.Add(new Vector(200, 0, 0));
                _pathPoints.Add(new Vector(0, 100, 0));
                _pathPoints.Add(new Vector(200, 0, 0));
                _pathPoints.Add(new Vector(-500, 100, 0));

                enemy.Path = new Path(_pathPoints, 10);

            }

            else if (definition.EnemyType == "particlesNewTop")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, 200, 0));
                _pathPoints.Add(new Vector(500, 300, 0));
                _pathPoints.Add(new Vector(200, 200, 0));
                _pathPoints.Add(new Vector(0, 300, 0));
                _pathPoints.Add(new Vector(200, 200, 0));
                _pathPoints.Add(new Vector(-500, 300, 0));

                enemy.Path = new Path(_pathPoints, 5);

            }

            else if (definition.EnemyType == "particlesNewBottom")
            {
                List<Vector> _pathPoints = new List<Vector>();
                _pathPoints.Add(new Vector(1400, -200, 0));
                _pathPoints.Add(new Vector(500, -100, 0));
                _pathPoints.Add(new Vector(200, -200, 0));
                _pathPoints.Add(new Vector(0, -100, 0));
                _pathPoints.Add(new Vector(200, -200, 0));
                _pathPoints.Add(new Vector(-500, -100, 0));

                enemy.Path = new Path(_pathPoints, 10);

            }
            else
            {
                System.Diagnostics.Debug.Assert(false, "Unknown enemy type.");
            }
            return enemy;
        }
 internal void OnCollision(Enemy enemy)
 {
 }
Esempio n. 4
0
 public void UpdatePosition(double elapsedTime, Enemy enemy)
 {
     _tween.Update(elapsedTime);
     Vector position = _spline.GetPositionOnLine(_tween.Value());
     enemy.SetPosition(position);
 }
Esempio n. 5
0
        private void MoveTo(Location newLocation)
        {
            //Does the location have required items
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this place.");
                return;
            }

            //update player's current location
            CurrentLocation = newLocation;

            //heal player
            CurrentHP = MaxHP;

            //does location have quest?
            if (newLocation.QuestAvailableHere != null)
            {
                //See if player already has quest and if completed
                bool playerHasQuest       = HasThisQuest(newLocation.QuestAvailableHere);
                bool playerCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                //see if player already has quest
                if (playerHasQuest)
                {
                    //if player has not completed quest
                    if (!playerCompletedQuest)
                    {
                        //see if player has all items to complete quest
                        bool playerHasItemsForQuest = HasItemsForQuest(newLocation.QuestAvailableHere);

                        //player has all items to complete quest
                        if (playerHasItemsForQuest)
                        {
                            //display message
                            RaiseMessage("You complete the " + newLocation.QuestAvailableHere.Name + " quest.");

                            //remove quest items from inventory
                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            //Give quest rewards
                            RaiseMessage("You receive: ");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardEXP.ToString() + " EXP");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardGold.ToString() + " Gold");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name);

                            AddEXP(newLocation.QuestAvailableHere.RewardEXP);
                            Gold += newLocation.QuestAvailableHere.RewardGold;

                            //add reward item to inventory
                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            //mark quest as completed
                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    //player does not already have quest

                    //display messages
                    RaiseMessage("You receive the " + newLocation.QuestAvailableHere.Name + " quest.");
                    RaiseMessage(newLocation.QuestAvailableHere.Description);
                    RaiseMessage("To complete it, return with:");
                    foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.Name);
                        }
                        else
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.NamePlural);
                        }
                    }

                    //add quest to quest list
                    Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
                }
            }

            //Does location have enemy?
            if (newLocation.EnemyLivingHere != null)
            {
                RaiseMessage("You see a " + newLocation.EnemyLivingHere.Name);

                //make new enemy using values from std enemy in World.Enemy list
                Enemy standardEnemy = World.EnemyById(newLocation.EnemyLivingHere.ID);

                _currentEnemy = new Enemy(standardEnemy.ID, standardEnemy.Name,
                                          standardEnemy.MaxDamage, standardEnemy.RewardEXP, standardEnemy.RewardGold, standardEnemy.CurrentHP, standardEnemy.MaxHP);

                foreach (LootItem lootItem in standardEnemy.LootTable)
                {
                    _currentEnemy.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentEnemy = null;
            }
        }