Ejemplo n.º 1
0
        public Unit(string spritePath, Team team, Point position, Type type)
        {
            _handle = GoodRnd.gen.Next(Int32.MinValue, Int32.MaxValue);
            if (team == Team.Red)
            {
                spritePath = @"red/" + spritePath;
            }
            else
            {
                spritePath = @"blu/" + spritePath;
            };
            _sprite = new Image(spritePath);
            Bar     = new Text(16);

            _team = team;
            X     = position.X;
            Y     = position.Y;

            _type = type;

            _direction = new Vector2(0);

            if (_team == Team.Red)
            {
                Teams.redTeam.Add(this);
                _targetPoint = new Point(Global.bluAncientCoords.X, 900);
            }
            else
            {
                StatisticWatcher.trackUnitsProduced(1);
                Teams.bluTeam.Add(this);
                _targetPoint = new Point(Global.redAncientCoords.X, -100);
            }
        }
Ejemplo n.º 2
0
 public override void Update()
 {
     if (gameStarted && !Global.isGamePaused)
     {
         Bot.Update();
         if (Global.tick % StatisticWatcher.updatePeriod == 0)
         {
             StatisticWatcher.trackPoints(Global.tick);
         }
         if (Global.tick++ % 500 == 0)
         {
             StatisticWatcher.trackCoins(1);
             Teams.playerBlue.AddCoin();
             Teams.playerRed.AddCoin();
         }
     }
 }
Ejemplo n.º 3
0
        public virtual void Damage(int damagePure)
        {
            var damageDealt = Convert.ToInt32(Math.Round(damagePure * Math.Pow(Global.damageReducingCoefficient, _armor * Global.armorMultifier), MidpointRounding.ToEven) - GoodRnd.gen.Next(-1, 1));

            if (_team == Team.Blu)
            {
                StatisticWatcher.trackDamageDone(damageDealt);
            }
            _hp -= damageDealt;
            if (_hp <= 0 && alive)
            {
                isAlive = false;
                GameScene.Instance.RemoveGraphic(Bar);

                for (var i = 0; i < 20; i++)
                {
                    GameScene.Instance.Add(new Particle(X, Y, Assets.ParticleBlood, 4, 4)
                    {
                        LifeSpan       = 50,
                        Angle          = 10,
                        FinalAlpha     = 0,
                        FinalX         = X + GoodRnd.gen.Next(-20, 20) * (float)GoodRnd.gen.NextDouble(),
                        FinalY         = Y + GoodRnd.gen.Next(-20, 20) * (float)GoodRnd.gen.NextDouble(),
                        FinalScaleX    = 0.5f,
                        LockScaleRatio = true
                    });
                }
                if (_team == Team.Red)
                {
                    StatisticWatcher.trackUnitsKilled(1);
                    StatisticWatcher.trackCoins(1);
                    Teams.redTeam.Remove(this);
                    Teams.redTeam.TrimExcess();
                    Teams.playerBlue.AddCoin();
                    GameScene.Instance.Add(new Label(X, Y - Graphic.HalfHeight, "+1", Color.Gold, 40, true, 10));
                }
                else
                {
                    Teams.bluTeam.Remove(this);
                    Teams.bluTeam.TrimExcess();
                    Teams.playerRed.AddCoin();
                }
                RemoveSelf();
            }
        }
Ejemplo n.º 4
0
        public void Heal(int value)
        {
            if (_hp == _maxhp)
            {
                return;
            }
            var prevHP = _hp;

            _hp += _maxhp * value / 100;
            if (_hp > _maxhp)
            {
                _hp = _maxhp;
            }
            if (_team == Team.Blu)
            {
                StatisticWatcher.trackHealthHealed(_hp - prevHP);
            }
        }