Ejemplo n.º 1
0
 private static void Loading_OnLoadingComplete(EventArgs args)
 {
     Menu = MainMenu.AddMenu("Activator", "activatorMenu");
     ItemManager.Init();
     SummonerSpells.Init();
     Defence.Init();
 }
 private void Start()
 {
     health  = statHolder.FindPropertyByName("Health") as Health;
     defence = statHolder.FindPropertyByName("Defence") as Defence;
     speed   = statHolder.FindPropertyByName("Speed") as Speed;
     attack  = statHolder.FindPropertyByName("Attack") as Attack;
 }
            // returns initial state
            private State InitStates()
            {
                aiTools = GetComponent <AiTools>();
                aiTools.Init();
                SearchEnemy      searchEnemyState      = new SearchEnemy(aiTools);
                SearchHealthPack searchHealthPackState = new SearchHealthPack(aiTools);
                Attack           attackState           = new Attack(aiTools);
                Defence          defenceState          = new Defence(aiTools);

                searchEnemyState.AddTransition(
                    new Transition(
                        () => aiTools.agentState.isEnemyVisible,
                        attackState
                        )
                    );

                searchEnemyState.AddTransition(
                    new Transition(
                        () => (aiTools.world.healthPacksAvailable > 0) && (aiTools.agentState.health <= GameDefines.LOW_HP),
                        searchHealthPackState
                        )
                    );

                attackState.AddTransition(
                    new Transition(
                        () => (aiTools.agentState.health <= GameDefines.MEDIUM_HP),
                        defenceState
                        )
                    );

                attackState.AddTransition(
                    new Transition(
                        () => (aiTools.agentState.health > GameDefines.MEDIUM_HP) && !aiTools.agentState.isEnemyVisible,
                        searchEnemyState
                        )
                    );

                defenceState.AddTransition(
                    new Transition(
                        () => (aiTools.world.healthPacksAvailable > 0) && ((aiTools.agentState.health <= GameDefines.LOW_HP) || !aiTools.agentState.isEnemyVisible),
                        searchHealthPackState
                        )
                    );

                defenceState.AddTransition(
                    new Transition(
                        () => (!aiTools.agentState.isEnemyVisible && ((aiTools.world.healthPacksAvailable == 0) || aiTools.agentState.health > GameDefines.LOW_HP)),
                        searchEnemyState
                        )
                    );

                searchHealthPackState.AddTransition(
                    new Transition(
                        () => (aiTools.agentState.health > GameDefines.LOW_HP) || (aiTools.world.healthPacksAvailable == 0),
                        searchEnemyState
                        )
                    );

                return(searchEnemyState);
            }
Ejemplo n.º 4
0
 /// <summary>
 /// Deploys a defence on the tile
 /// </summary>
 /// <param name="def">Defence to deploy</param>
 public void AddDefence(Defence def)
 {
     this.Defence = def;              //Updates defence
     def.Tile     = this;             //Sets tile
     this.World.SpendMoney(def.Cost); //Takes money from player
     this.World.UpdateRiskMap();      //Updates risk map
 }
Ejemplo n.º 5
0
 /// <inheritdoc/>
 public override bool DoesModelPassFilter(string filter) =>
 Gender.ToString().Contains(filter, StringComparison.OrdinalIgnoreCase) ||
 Name.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
 Defence.ToString().Contains(filter) ||
 Evasion.ToString().Contains(filter) ||
 Effect.Contains(filter, StringComparison.OrdinalIgnoreCase) ||
 Obtained.Any(obtained => obtained.DoesModelPassFilter(filter));
Ejemplo n.º 6
0
 private void Defend()
 {
     FortifyTarget(ref CharacterParty[ActiveCharacter].DefenceBuffList,
                   Defence.OneTurn(CharacterParty[ActiveCharacter].CurrentDefence));
     StatusHandler.Add(ref CharacterParty[ActiveCharacter].StatusList, new Status(StatusType.DefenceUp, 1));
     AdvanceTurn();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Starts the next wave
        /// </summary>
        public void StartNextWave()
        {
            this.WaveNumber++;                                                                //Increments wave number

            this.resources     = GetWaveResources(this.WaveNumber);                           //Updates resources
            this.spawnCooldown = GetSpawnCooldown(this.WaveNumber);                           //Updates cooldown

            this.target = null;                                                               //Sets target to null

            foreach (Tile tile in this.world.Grid)                                            //Looops through each tile
            {
                if (tile.Defence != null && tile.Defence.Kills > this.world.TotalKills * 0.6) //If the defence has 60% of kills
                {
                    this.target = tile.Defence;                                               //Its is targeted
                }
            }

            //Adds as many powerful enemies as possible to the spawn queue
            foreach (Enemy enemy in Enemy.Types)
            {
                while (this.resources >= enemy.Cost)                                     //Whilst the AI can afford
                {
                    this.resources -= enemy.Cost;                                        //Reduces resources
                    Enemy   newEnemy = (Enemy)Activator.CreateInstance(enemy.GetType()); //Creates a new enemy
                    Vector2 loc      = this.GetRandomSpawnLoc();                         //Location to spawn at
                    this.spawnQueue.Enqueue(new EnemySpawn(loc, newEnemy));              //Creates and adds pair to queue
                }
            }

            this.IsWaveActive = true; //Sets wave to active
        }
Ejemplo n.º 8
0
            public DefencePanel(Defence d, World w, Rectangle rectangle) : base(d.GetGraphic(), rectangle)
            {
                this.Defence = d;
                this.world   = w;

                this.costLabel = new UILabel(d.Cost.ToString(), Graphics.arial16, Color.White, new Point(this.Bounds.Left, this.Bounds.Bottom - 20));
                this.Children.Add(this.costLabel);
            }
Ejemplo n.º 9
0
 /// <summary>
 /// Deletes the enemy from existance
 /// </summary>
 public virtual void Die(Defence defence)
 {
     this.World.AddMoney((int)(this.Cost * 1.5 * ((SiegeGame.Random.Next(10) / 9) + 1)));
     defence.Kills++;
     this.World.TotalKills++;
     this.World.GetTileAt(this.Location).Enemies.Remove(this); //Removes from tile
     this.World.Enemies.Remove(this);                          //Removes from world
 }
Ejemplo n.º 10
0
        public World(SiegeGame game, string[] setup)
        {
            this.Game    = game;               //Sets game
            this.Enemies = new List <Enemy>(); //New list of enemies

            string[] worldSetup = setup[0].Split(',');

            if (worldSetup.Length == 4)
            {
                this.WaveController = new WaveController(this)
                {
                    WaveNumber = int.Parse(worldSetup[0])
                };

                //Money
                this.Money = int.Parse(worldSetup[1]);

                //Grid size
                worldSetup[2] = worldSetup[2].Trim(new Char[] { '[', ']' });
                this.CreateGrid(int.Parse(worldSetup[2].Substring(0, worldSetup[2].IndexOf("|"))), int.Parse(worldSetup[2].Remove(0, worldSetup[2].IndexOf("|") + 1)));

                //Total kills
                this.TotalKills = int.Parse(worldSetup[3]);
            }

            for (int i = 1; i < setup.Length; i++)
            {
                List <string> defenceInfo = new List <string>(setup[i].Split(','));

                if (defenceInfo[0] == new CrownDef().GetType().ToString())
                {
                    this.GetTileAt(this.GetCrownLocation()).Defence.Health = int.Parse(defenceInfo[2]);
                }
                else
                {
                    foreach (Defence d in Defence.Types)
                    {
                        if (defenceInfo[0] == d.GetType().ToString())
                        {
                            Defence defence = (Defence)Activator.CreateInstance(d.GetType());
                            defenceInfo[1] = defenceInfo[1].Trim(new Char[] { '[', ']' });
                            this.GetTileAt(int.Parse(defenceInfo[1].Substring(0, defenceInfo[1].IndexOf("|"))), int.Parse(defenceInfo[1].Remove(0, defenceInfo[1].IndexOf("|") + 1))).SetDefence(defence);
                            defenceInfo.RemoveRange(0, 2);
                            defence.LoadData(defenceInfo.ToArray());
                        }
                    }
                }
            }

            this.UpdateRiskMap(); //Updates the risk map


            //Testing def panel
            //this.defenceSelectPanel = new DefenceSelectPanel(this, new Rectangle(0, 0, 202, 390), new List<Defence>() { new StoneWallDef(), new GuardDef(), new DummyDef(Graphics.Graphics.archerDef), new DummyDef(Graphics.Graphics.catapultDef) });
            this.IsRunning = true;
            this.isPaused  = false;
        }
Ejemplo n.º 11
0
        public ActionResult DeleteConfirmed(int author, int id)
        {
            int     uid     = db.Disser.Where(x => x.AuthorPass == author).Single().Work.Id;
            Defence defence = db.Defence.Find(id, author, uid);     //находим защиту

            db.Defence.Remove(defence);                             //удаляем защиту
            db.SaveChanges();                                       //накатываем изменения
            return(RedirectToAction("Index", new { id = author })); //к списку
        }
    private void SetupDefence()
    {
        for (int cnt = 0; cnt < _defence.Length; cnt++)
        {
            _defence [cnt]      = new Defence();
            _defence [cnt].Name = ((DefenceName)cnt).ToString();
        }

        SetupDefenceModifier();
    }
Ejemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "Number,AuthorPass,DisserId,Date,Opponent,Opponent2,Result,City,Organisation,Building,Auditory")] Defence defence)
 {
     if (ModelState.IsValid)                                                 //Если все введено верно
     {
         db.Entry(defence).State = EntityState.Modified;                     //ставим статус "изменено"
         db.SaveChanges();                                                   //накатываем изменения
         return(RedirectToAction("Index", new { id = defence.AuthorPass })); //обратно к списку
     }
     ViewBag.DisserId = db.Disser.Where(x => x.AuthorPass == defence.AuthorPass).Single().Id;
     return(View(defence)); //иначе все по-новой
 }
Ejemplo n.º 14
0
 public override void TakeDamage(float damage)
 {
     if (Random.Range(0, 100) >= Agility.GetValue())
     {
         damage              -= Defence.GetValue();
         damage               = Mathf.Clamp(damage, 0, int.MaxValue);
         CurrentHealth       -= damage;
         Healthbar.fillAmount = CurrentHealth / MaxHealth.GetValue();
         Debug.Log("Damage has been taken " + damage);
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Reduces the enemy health by a set amount
 /// </summary>
 /// <param name="damage">Amount of damage</param>
 public void DealDamage(int damage, Defence defence)
 {
     if (this.Health - damage > 0)
     {
         this.Health -= damage; //Health is reduced b damage
     }
     else
     {
         this.Die(defence); //If health is less than or equal to zero the enemy dies
     }
 }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            Defence         de     = new Defence(30, 25, 26, 24);
            BaseSkills      bs     = new BaseSkills(20, 20, 15, 22, 19, 10);
            Traits          tr     = new Traits(9, 12, 7, 15, 12, 9, 11, 11, 18, 12, 11, 9, 16, 20, 13, 12, 12);
            PlayerCharacter WE     = new PlayerCharacter("Wuihtentrein Eihset", new Human(), 174, 64, 180, de, 16, bs, tr);
            Player          player = new Player("BA", WE);

            Console.WriteLine(player.ToString());

            char a = Console.ReadKey(true).KeyChar;
        }
Ejemplo n.º 17
0
        public ActionResult Create([Bind(Include = "Number,AuthorPass,DisserId,Date,Opponent,Opponent2,Result,City,Organisation,Building,Auditory")] Defence defence)
        {
            if (ModelState.IsValid)                                                 //если все вбито правильно
            {
                db.Defence.Add(defence);                                            //добавляем защиту
                db.SaveChanges();                                                   //накатываем изменения
                return(RedirectToAction("Index", new { id = defence.AuthorPass })); //обратно к списку
            }

            ViewBag.DisserId = db.Disser.Where(x => x.AuthorPass == defence.AuthorPass).Single().Id; //иначе
            return(View(defence));                                                                   //еще раз
        }
Ejemplo n.º 18
0
 /// <summary>
 /// hash kodo metodas
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(Name.GetHashCode() ^
            Role.GetHashCode() ^
            HitPoints.GetHashCode() ^
            Mana.GetHashCode() ^
            Damage.GetHashCode() ^
            Defence.GetHashCode() ^
            Strength.GetHashCode() ^
            Agility.GetHashCode() ^
            Intelligence.GetHashCode() ^
            Power.GetHashCode());
 }
Ejemplo n.º 19
0
        public Tile(World w, Vector2 l, Defence d)
        {
            this.World = w;

            this.Location = l;

            this.Defence = d;

            if (this.Defence != null)
            {
                this.Defence.Tile = this;      //If there is a defence then the tile of the defence is set
            }
            this.Enemies = new List <Enemy>(); //Creates a new list of enemies
        }
Ejemplo n.º 20
0
        public ActionResult Details(int?author, int?id)                                      //защита с конкретным номером для аспиранта
        {
            if (id == null || author == null || !db.Aspirant.Any(x => x.Pass == author))     //если хоть чего-то нет
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));                 //ошибка!
            }
            int     uid     = db.Disser.Where(x => x.AuthorPass == author).Single().Work.Id; //забираем Id диссертации
            Defence defence = db.Defence.Find(id, author, uid);                              //находим защиту

            if (defence == null)                                                             //если не нашли
            {
                return(HttpNotFound());                                                      //ошибка!
            }
            return(View(defence));                                                           //показываем защиту
        }
    private void Start()
    {
        statholder    = Body.GetComponent <StatHolder>();
        bodyAnimator  = Body.GetComponent <Animator>();
        handsAnimator = Hands.GetComponent <Animator>();

        Attack attack = statholder.FindPropertyByName("Attack") as Attack;

        bosshealth = statholder.FindPropertyByName("Health") as Health;

        GameObject Player  = GameObject.FindGameObjectWithTag("Player");
        Defence    defence = Player.GetComponent <StatHolder>().FindPropertyByName("Defence") as Defence;

        attack.runtimeBaseValue = defence.runtimeBaseValue + 1;
    }
Ejemplo n.º 22
0
        public ActionResult Delete(int?author, int?id)
        {
            if (id == null || author == null || !db.Aspirant.Any(x => x.Pass == author)) //чего-то нет?
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));             //ошибка!
            }
            int     uid     = db.Disser.Where(x => x.AuthorPass == author).Single().Work.Id;
            Defence defence = db.Defence.Find(id, author, uid); //находим защиту

            if (defence == null)                                //не нашли?
            {
                return(HttpNotFound());                         //ошибка!
            }
            return(View(defence));                              //показываем представление
        }
Ejemplo n.º 23
0
        public ActionResult Edit(int?author, int?id)                                         //изменяем конкретную защиту
        {
            if (author == null || !db.Aspirant.Any(x => x.Pass == author))                   //нет автора?
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));                 //ошибка!
            }
            int     uid     = db.Disser.Where(x => x.AuthorPass == author).Single().Work.Id; //находим Id
            Defence defence = db.Defence.Find(id, author, uid);                              //находим защиту

            if (defence == null)                                                             //не нашли защиту?
            {
                return(HttpNotFound());                                                      //ошибка!
            }
            ViewBag.DisserId = db.Disser.Where(x => x.AuthorPass == defence.AuthorPass).Single().Id;
            return(View(defence));//передаем айди в представление и переходим туда
        }
Ejemplo n.º 24
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            //Console.WriteLine(this.Children.Count);

            if (!this.World.isPaused)
            {
                Rectangle mouseRectangle = new Rectangle(SiegeGame.currentMouse.X, SiegeGame.currentMouse.Y, 1, 1); //Pos of the current mouse


                if (SiegeGame.currentMouse.LeftButton == ButtonState.Released && SiegeGame.prevMouse.LeftButton == ButtonState.Pressed)
                {
                    //Code for dropping def
                    if (this.SelectedDefence != null)
                    {
                        //Gets grid location, however the method should return false if this is not valid so nothing should happen if the user attempts to place the defence somewhere that isn't a tile
                        if (this.World.GetLocationFromScreen(Mouse.GetState().Position.ToVector2(), out Vector2 gridLoc))
                        {
                            //Gets the tile from the location using a floor method
                            Tile tile = this.World.GetTileAt(gridLoc);

                            //If a defence can be placed on the tile then the selected defence will be placed
                            if (!(tile is SpawnTile) && tile.Defence == null)
                            {
                                tile.AddDefence((Defence)Activator.CreateInstance(this.SelectedDefence.GetType()));
                            }
                        }
                        this.SelectedDefence = null;
                    }
                }
                else if (SiegeGame.currentMouse.LeftButton == ButtonState.Pressed && SiegeGame.prevMouse.LeftButton == ButtonState.Released)
                {
                    //Code for picking up a defence
                    foreach (DefencePanel defence in this.Children)
                    {
                        if (mouseRectangle.Intersects(defence.Bounds) && (defence.Defence.Cost <= this.World.Money))
                        {
                            this.SelectedDefence = defence.Defence; //Sets the held defence
                        }
                    }
                }

                //Debugging
                //Console.WriteLine(this.SelectedDefence);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        ///Construtor da classe "Bala".
        ///É responsavável por todas as variáveis que definem uma bala
        /// </summary>
        /// <param name="contents">Instâcia de ContentManager</param>
        /// <param name="assetName">Nome da textura da bala</param>
        /// <param name="direccao">Direção do ecrã em que a bala se move</param>
        /// <param name="origemBala">Entidade que disparou a bala</param>
        /// <param name="direccaobala">Tipo de bala - frente, cima, baixo</param>
        /// <param name="parent">Turret que originou a bala</param>
        public Bala(ContentManager contents, string assetName, int direccao, OrigemBala origemBala, DireccaoBala direccaobala, Defence parent = null)
            : base(contents, assetName)
        {
            base.spriteEffects = direccao > 0 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
            this.speed         = Camera.velocidadegeral;
            this.direccaobala  = direccaobala;
            this.direccao      = direccao;
            this.origemBala    = origemBala;
            this.parent        = parent;
            direction          = Vector2.Zero;

            this.EnableCollisions();
            //else
            //{
            //    som.playTiroEnimigo(contents);
            //}
        }
Ejemplo n.º 26
0
 private void FortifyDecrease(ref List <Defence> DefenceBuffList)
 {
     for (int i = 0; i < DefenceBuffList.Count; i++)
     {
         if (DefenceBuffList[i].DefenceLength <= 1)
         {
             DefenceBuffList.RemoveAt(i);
             i--;
         }
         else
         {
             Defence Temp = DefenceBuffList[i];
             Temp.DefenceLength--;
             DefenceBuffList[i] = Temp;
         }
     }
 }
Ejemplo n.º 27
0
    public void OnEquipmentChanged(EquipmentScript ItemToAdd, EquipmentScript ItemToRemove)
    {
        if (ItemToAdd != null)
        {
            Defence.AddModifier(ItemToAdd.defenceModifier);

            Damage.AddModifier(ItemToAdd.damageModifier);

            Agility.AddModifier(ItemToAdd.agilityModifier);
        }

        if (ItemToRemove != null)
        {
            Defence.RemoveModifier(ItemToRemove.defenceModifier);

            Damage.RemoveModifier(ItemToRemove.damageModifier);

            Agility.RemoveModifier(ItemToRemove.agilityModifier);
        }
    }
Ejemplo n.º 28
0
        // GET: Votings
        public ActionResult Index(int?author, int?id)
        {
            if (author == null || id == null) //проверяем на существование или ошибка
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Disser  d   = db.Disser.Where(x => x.AuthorPass == author).SingleOrDefault(); //находим диссертацию
            Defence def = db.Defence
                          .Where(x => (x.DisserId == d.Id && (x.Number == id) && x.AuthorPass == author))
                          .SingleOrDefault(); //и защиту
            Voting voting = db.Voting
                            .Where(x => x.DisserId == def.DisserId && x.AuthorPass == def.AuthorPass && x.DefenceId == def.Number)
                            .SingleOrDefault(); //и голосование

            if (voting != null)
            {
                return(View("Details", voting)); //если уже есть голосование, то смотрим его
            }
            ViewBag.Defence = def;
            return(View("Create"));//иначе создаем новое
        }
Ejemplo n.º 29
0
    public LocalObject(LocalShape localShape, string _uniqueName = "", Inventory _inventory = null)
    {
        uniqueName = _uniqueName;
        shape = new ShapeComponent(localShape, this);

        if (localShape.type == LocalType.Get("Destructible") || localShape.type == LocalType.Get("Container"))
        {
            hp = new HPComponent(this);
        }
        else if (localShape.type == LocalType.Get("Creature"))
        {
            hp = new HPComponent(this);
            movement = new Movement(this);
            defence = new Defence(this);
            attack = new Attack(this);
            abilities = new Abilities(this);
            fatigue = new Fatigue(this);
            eating = new Eating(this);
        }

        if (_inventory != null)
        {
            inventory = new Inventory(6, 1, "", false, null, this);
            _inventory.CopyTo(inventory);
        }
    }
Ejemplo n.º 30
0
    public LocalObject(string _uniqueName, Race _race, CharacterClass _cclass, Background _background, Origin _origin, int experience)
    {
        uniqueName = _uniqueName;
        race = _race;
        cclass = _cclass;
        background = _background;
        origin = _origin;

        xp = new Experience(experience, this);

        skills = new Skills(this);
        inventory = new Inventory(6, 1, "", true, null, this);

        hp = new HPComponent(this);
        movement = new Movement(this);
        defence = new Defence(this);
        attack = new Attack(this);
        abilities = new Abilities(this);
        fatigue = new Fatigue(this);
        eating = new Eating(this);
    }
Ejemplo n.º 31
0
 protected void CloneTo(Armor item)
 {
     base.CloneTo(item);
     item.Defence = (MainStat <long>)Defence.Clone();
 }
    private void SetupDefence()
    {
        for (int cnt = 0; cnt <_defence.Length; cnt++) {
            _defence [cnt] = new Defence ();
            _defence [cnt].Name = ((DefenceName)cnt).ToString();
        }

        SetupDefenceModifier ();
    }
Ejemplo n.º 33
0
 public SpawnTile(World w, Vector2 l, Defence d) : base(w, l, d)
 {
 }