Update() public method

public Update ( ) : void
return void
        public void LoadData()
        {
            Dataset.Clear();
            if (CharactersViewModel.Instance.Dataset.Count == 0)
            {
                CharactersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            else if (CharactersViewModel.Instance.NeedsRefresh())
            {
                CharactersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            var dataset   = CharactersViewModel.Instance.GetAllCreatures();
            int teamCount = 0;

            foreach (var data in dataset)
            {
                if ((data.Type == 0) && (teamCount < 6))//&& data.OnTeam)//the creature is a character, the team is not full, and it is on the current team
                {
                    teamCount++;
                    Creature newOne = new Creature();
                    newOne.Update(data);
                    newOne.Id = Guid.NewGuid().ToString();
                    Dataset.Add(newOne);
                }
            }
        }
Ejemplo n.º 2
0
 void Update()
 {
     //amoeba2.Update();
     amoeba.Update();
     blinker.Update();
     glider.Update();
     tower.Update();
 }
Ejemplo n.º 3
0
        public void setMonsters()
        {
            Dataset.Clear();
            //LoadDataCommand = new Command(async () => await ExecuteLoadDataCommand());
            if (MonstersViewModel.Instance.Dataset.Count == 0)
            {
                MonstersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            else if (MonstersViewModel.Instance.NeedsRefresh())
            {
                MonstersViewModel.Instance.LoadDataCommand.Execute(null);
            }
            var    dataset     = MonstersViewModel.Instance.GetAllCreatures();
            var    tempDataset = new List <Creature>();
            int    dateSeed    = DateTime.Now.Millisecond;
            Random rand        = new Random(dateSeed);

            foreach (var data in dataset)
            {
                if (data.Type == 1)// just Monsters
                {
                    Creature newOne = new Creature();
                    newOne.Update(data);

                    tempDataset.Add(newOne);
                }
            }
            for (int i = 0; i < 6; i++)
            {
                int index = rand.Next(tempDataset.Count);
                if (GameGlobals.DisableRandomNumbers)
                {
                    index = 0;
                }
                Creature monster = new Creature();
                monster.Update(tempDataset[index]);         //get a random monster type
                monster.Id      = "monster" + i.ToString(); //Guid.NewGuid().ToString();
                monster.Alive   = true;
                monster.Level   = round;
                monster.XP      = lp[round].XP;
                monster.Attack  = lp[round].Attack;
                monster.Defense = lp[round].Defense;
                monster.Speed   = lp[round].Speed;
                int healthRand = rand.Next(11);
                if (GameGlobals.DisableRandomNumbers)
                {
                    healthRand = 1;
                }
                monster.MaxHealth   = healthRand * round;
                monster.CurrHealth  = monster.MaxHealth;
                monster.RHandItemID = "bow";//              ***temp for demo***
                monster.BodyItemID  = "helmet";
                monster.FeetItemID  = "boots";
                Dataset.Add(monster);
            }
        }
Ejemplo n.º 4
0
        //loading the characters in the team
        public void LoadTeam()
        {
            Dataset.Clear();
            var dataset = CharactersViewModel.Instance.Dataset;

            int teamCount = 0;

            foreach (var data in dataset)
            {
                if ((data.Type == 0) && (teamCount < 6) && (data.OnTeam))//the creature is a character, the team is not full, and it is on the current team
                {
                    teamCount++;
                    Creature newOne = new Creature();
                    newOne.Update(data);
                    newOne.Id = Guid.NewGuid().ToString();
                    Dataset.Add(newOne);
                }
            }
            if (teamCount < 6)
            {
                foreach (var data in dataset)                                  //if the team is not full more characters must be added
                {
                    if ((data.Type == 0) && (teamCount < 6) && (!data.OnTeam)) //the creature is a character, the team is not full, and the character is not in the team
                    {
                        teamCount++;
                        data.OnTeam = true;
                        Creature newOne = new Creature();
                        newOne.Update(data);
                        newOne.Id = Guid.NewGuid().ToString();
                        Dataset.Add(newOne);
                    }
                }
            }
            if (teamCount < 6)//if you didn't make enough characters you get some sucky ones
            {
                int numOfSuckyCharacters = 0;
                for (int i = teamCount; i < 6; i++)
                {
                    numOfSuckyCharacters++;
                    Creature character = new Creature();
                    character.Id         = Guid.NewGuid().ToString();
                    character.Type       = 0;
                    character.OnTeam     = true;
                    character.Name       = "Sucky Character " + numOfSuckyCharacters.ToString();
                    character.Attack     = 1;
                    character.Defense    = 1;
                    character.Speed      = 1;
                    character.MaxHealth  = 1;
                    character.CurrHealth = character.MaxHealth;
                    character.ImageURI   = "superman.jpeg";
                    Dataset.Add(character);
                    MessagingCenter.Send(this, "AddData", character);
                }
            }
        }
Ejemplo n.º 5
0
 public void SetBattleController(int round)
 {
     CurrMonsters.setRound(round);//Monsters will reset for every round
     CurrMonsters.setMonsters();
     originalMonsters.RemoveRange(0, originalMonsters.Count);
     foreach (Creature monster in CurrMonsters.Dataset)
     {
         Creature tempMonster = new Creature();
         tempMonster.Update(monster);
         tempMonster.Id = monster.Id;
         originalMonsters.Add(tempMonster);//save the monster set before the battle for the score
     }
     TurnOrder = GetTurnOrder();
     InitializeGameBoard();//GameBoard will be initialized
 }
Ejemplo n.º 6
0
        public void Update()
        {
            if (!finished)
            {
                timer += Time.deltaTime;
                creature.Update();

                if (timer > testTime)
                {
                    endCenterOfMass = CalculateMeanCenterOfMass();
                    float distanceTravelled = Vector2.Distance(new Vector2(initialCenterOfMass.x, initialCenterOfMass.z), new Vector2(endCenterOfMass.x, endCenterOfMass.z));
                    creature.fitness = distanceTravelled;
                    finished         = true;
                    sLD.SaveCreature(creature, test, generation);
                    Destroy(creature.handle);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            KeyboardState keys  = Keyboard.GetState();
            MouseState    mouse = Mouse.GetState();


            if (keys.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            player.Update(gameTime);
            creature.Update(gameTime);
            creature.Updatee(gameTime, mapView.X, mapView.Y);

            Rectangle delta = mapView;

            if (keys.IsKeyDown(Keys.Down))
            {
                delta.Y += 1;
                player.MoveSprite(gameTime);
                player.MoveDown(this.Content);
            }

            if (keys.IsKeyDown(Keys.Up))
            {
                delta.Y -= 1;
                player.MoveSprite(gameTime);
                player.MoveUp(this.Content);
            }

            if (keys.IsKeyDown(Keys.Right))
            {
                delta.X += 1;
                player.MoveSprite(gameTime);
                player.MoveRight(this.Content);
            }

            if (keys.IsKeyDown(Keys.Left))
            {
                delta.X -= 1;
                player.MoveSprite(gameTime);
                player.MoveLeft(this.Content);
            }

            if (maps[mapIdx].Bounds.Contains(delta))
            {
                player.position.X += delta.X - mapView.X;
                player.position.Y += delta.Y - mapView.Y;
                mapView.X          = delta.X;
                mapView.Y          = delta.Y;
            }
            //exitButtonSourceRect = new Rectangle(0, 0, 100, 100);
            exitButton.Update(gameTime);
            base.Update(gameTime);
        }
        //creates a new set of monsters on every round
        public void setMonsters()
        {
            Dataset.Clear();
            var dataset = MonstersViewModel.Instance.Dataset;

            var    tempDataset = new List <Creature>();
            int    dateSeed    = DateTime.Now.Millisecond;
            Random rand        = new Random(dateSeed);

            foreach (var data in dataset)
            {
                if (data.Type == 1)                   // just Monsters
                {
                    Creature newOne = new Creature(); //makes sure that the actual data is not changed
                    newOne.Update(data);

                    tempDataset.Add(newOne);
                }
            }
            //create the monsters for the current round
            for (int i = 0; i < 6; i++)
            {
                int Round = round;
                if (round > 20)
                {
                    Round = 20;
                }
                int      index   = rand.Next(tempDataset.Count);
                Creature monster = new Creature();
                monster.Update(tempDataset[index]);//get a random monster type then update the data for the current round
                monster.Id        = Guid.NewGuid().ToString();
                monster.Alive     = true;
                monster.Level     = Round;
                monster.XP        = lp[Round].XP;
                monster.Attack    = lp[Round].Attack;
                monster.Defense   = lp[Round].Defense;
                monster.Speed     = lp[Round].Speed;
                monster.MaxHealth = rand.Next(1, 11) * Round;
                if (round == 1)
                {
                    monster.MaxHealth = 1;//round 1 monsters are freebies
                    monster.XP        = 100;
                }
                monster.CurrHealth = monster.MaxHealth;

                // Load items
                var myItemViewModel = ItemsViewModel.Instance;
                var items           = myItemViewModel.Dataset;


                //check itemcount and assign random items to monster
                int itemCount = 0;
                while (itemCount < 3)
                {
                    var item         = items[rand.Next(items.Count)];
                    var itemLocation = item.Location;
                    if (item.Location == ItemLocationEnum.Finger)//watch out for the finger
                    {
                        itemLocation = ItemLocationEnum.RightFinger;
                    }
                    //if that location is available fill it, otherwise try again
                    if (monster.GetItemByLocation(itemLocation) == null)
                    {
                        monster.AddItem(itemLocation, item.Id);
                        itemCount++;
                    }
                }
                //load unique drop
                var uItem = items[rand.Next(items.Count)];
                monster.UniqueItem = uItem.Id;
                Dataset.Add(monster);
            }
        }
Ejemplo n.º 9
0
    public void TimeChange(int timeIndex)
    {
        parent = transform.parent.GetComponent <Creature>();

        if (parent.IsDead == false)
        {
            foreach (int ability in parent.Abilities)
            {
                if (ability == 4)                 //nightstalker
                {
                    if (timeIndex == 0)
                    {
                        parent.Strength -= 2;
                        parent.Health   += 1;
                    }

                    else if (timeIndex == 1)
                    {
                        parent.Strength -= 1;
                        parent.Health   += 2;
                    }
                    else if (timeIndex == 2)
                    {
                        parent.Strength += 3;
                        parent.Health   -= 3;
                    }
                }

                else if (ability == 5)                 //green flame
                {
                    if (timeIndex == 2)
                    {
                        parent.Strength += 2;
                        parent.Health   += 2;
                    }
                    else if (timeIndex == 1)
                    {
                        parent.Strength -= 1;
                        parent.Health   -= 1;
                    }
                    else if (timeIndex == 0)
                    {
                        parent.Strength -= 1;
                        parent.Health   -= 1;
                    }
                }

                else if (ability == 10)
                {
                    if (timeIndex == 1)
                    {
                        parent.Strength -= 2;
                    }
                    else if (timeIndex == 2)
                    {
                        parent.Strength += 2;
                    }
                }

                else if (ability == 16)
                {
                    if (timeIndex == 2)
                    {
                        parent.MaxAttacks = 2;
                    }
                    else if (timeIndex == 0)
                    {
                        parent.MaxAttacks = 1;
                    }
                }

                else if (ability == 18)                 // bard
                {
                    if (timeIndex == 2)
                    {
                        parent.Strength -= 1;
                        parent.Health   -= 1;
                    }
                    else if (timeIndex == 0)
                    {
                        parent.Strength += 1;
                        parent.Health   += 1;
                    }
                }

                else if (ability == 20)
                {
                    if (timeIndex == 2)
                    {
                        parent.Strength -= 2;
                    }
                    else if (timeIndex == 1)
                    {
                        parent.Strength += 1;
                    }
                    else if (timeIndex == 0)
                    {
                        parent.Strength += 1;
                    }
                }

                else if (ability == 22)
                {
                    if (timeIndex == 1)
                    {
                        parent.Strength += 2;
                    }
                    else if (timeIndex == 2)
                    {
                        parent.Strength -= 2;
                    }
                }

                else if (ability == 31)
                {
                    if (timeIndex == 2)
                    {
                        parent.Strength += 1;
                    }
                    else if (timeIndex == 0)
                    {
                        parent.Strength -= 1;
                    }
                }
            }

            parent.Update();
        }
    }