Esempio n. 1
0
        public Tower(BuilduingTypeInfo info, string type, Vector2 pos)
            : base(info, type, pos)
        {
            string[] coms = new string[info.Attacks.Length + info.SpawnAttacks.Length];


            meleAtks = new ArealAttack[info.Attacks.Length];
            int count = 0;

            foreach (AttackTypeInfo atk in info.Attacks)
            {
                coms[count]     = "Mele " + count;
                meleAtks[count] = new ArealAttack(atk, this);
                count++;
            }

            spawnAtks = new SpawnAttack[info.SpawnAttacks.Length];
            count     = 0;
            foreach (SpawnAttackTypeInfo atk in info.SpawnAttacks)
            {
                coms[count + meleAtks.Length] = atk.SpawnActor + "-" + atk.Number;
                spawnAtks[count] = new SpawnAttack(atk, this);
                count++;
            }

            menu = new ActorMenu(this, coms);
            menu.CommandInvoked += new MenuItemPressed(menu_CommandInvoked);
            curSpawn             = 0;
            curMele              = 0;
            updateMenuInfo();

            AI = new TowerAI(this);
        }
Esempio n. 2
0
 public override void IssueMeleeAttack(Vector2 loc)
 {
     if (MeleeAttack != null)
     {
         ArealAttack atk = MeleeAttack.GetInstance(loc);
         stage.InflictAttack(atk);
     }
 }
Esempio n. 3
0
 void changeAnim(ArealAttack damage, Actor attacker)
 {
     if (IsComplete)
     {
         if (this.Health > 0)
         {
             this.IdleAnimation.GoToFrameRatio(1 - this.HealthRatio);
         }
     }
 }
Esempio n. 4
0
        public void InflictAttack(ArealAttack atk)
        {
            var targets = Query(atk.AreaOfAffect);

            foreach (var target in targets)
            {
                if (target.Faction.GetRelationship(atk.Attacker.Faction) != FactionRelationship.Allied)
                {
                    target.OnAttacked(atk);
                }
            }
        }
Esempio n. 5
0
        public override void IssueMeleeAttack(Vector2 loc)
        {
            if (MeleeAttack != null)
            {
                ArealAttack atk = MeleeAttack.GetInstance(loc);
                stage.InflictAttack(atk);

                Effects.GraphicsEffect effect = MeleeAttack.CreateEffect(MeleeAttack.AreaOfAffect.MaxRadius, null, 0.0f);
                if (effect != null)
                {
                    stage.PushEffect(effect);
                }
            }
        }
Esempio n. 6
0
        public override void IssueMeleeAttack(Vector2 loc)
        {
            if (MeleeAttack != null)
            {
                PushAnimation(MeleeAnimation);

                ArealAttack atk = MeleeAttack.GetInstance(loc);
                stage.InflictAttack(atk);

                Effects.GraphicsEffect effect = MeleeAttack.CreateEffect(0.3f, null, 0.0f);
                if (effect != null)
                {
                    stage.PushEffect(effect);
                }
            }
        }
Esempio n. 7
0
        public FatherUnit(UnitTypeInfo info, string type, Vector2 pos)
            : base(UnitConverter.CreatePolygon(info.Polygon, pos))
        {
            this.Position = polygon.Center;
            this.Inertia  = info.Inertia;
            fullHp        = info.Health;
            Health        = info.Health;
            Defense       = new Damage(info.Defense);

            if ((info.Attacks.Length > 0) && !info.Attacks[0].Null)
            {
                mele = new ArealAttack(info.Attacks[0], this);
            }
            if (info.SpawnAttacks.Length != 0)
            {
                spAtk = new SpawnAttack(info.SpawnAttacks[0], this);
            }

            this.Type       = type;
            this.workPerSec = info.WorkPower;
            this.workPd     = info.WorkPeriod;

            this.MaxSpeed       = info.Speed;
            this.AI             = UnitConverter.CreateAI(info.AIType, this, MaxSpeed);
            this.CollisionClass = UnitConverter.CreateCollisionType(info.CollisionType);

            IdleAnimation   = UnitConverter.CreateAnimation(polygon, info.IdleAnimation);
            MoveAnimation   = UnitConverter.CreateAnimation(polygon, info.MoveAnimation);
            WorkAnimation   = UnitConverter.CreateAnimation(polygon, info.WorkAnimation);
            MeleeAnimation  = UnitConverter.CreateAnimation(polygon, info.MeleeAnimation);
            RangedAnimation = UnitConverter.CreateAnimation(polygon, info.RangedAnimation);

            SetBaseAnimation(IdleAnimation);

            this.SightRange = info.SightRange;

            unitMenu            = new ActorMenu(this);
            unitMenu.DisplayBar = true;

            IsRotatable = info.Rotatable;

            DrawDepth = Omron.Framework.DrawPriority.UnitDepth;
        }
Esempio n. 8
0
        public void OnAttacked(ArealAttack atk)
        {
            var damage = atk.Damage;

            this.Health -= damage.Slashing * Defense.Slashing;
            this.Health -= damage.Blunt * Defense.Blunt;
            this.Health -= damage.Pierce * Defense.Pierce;
            this.Health -= damage.Blight * Defense.Blight;
            this.Health -= damage.Mining * Defense.Mining;

            if (this.IsDead)
            {
                Die();
            }

            if (Attacked != null)
            {
                Attacked(atk, atk.Attacker);
            }
        }
Esempio n. 9
0
        public override void IssueMeleeAttack(Actor target)
        {
            if (MeleeAttack != null)
            {
                PushAnimation(MeleeAnimation);

                ArealAttack atk = MeleeAttack.GetInstance(Position);
                Vector2     dir = Vector2.Normalize((target.Position - this.Position));
                atk.AreaOfAffect.Rotation = MathHelper.GetAngle(dir);
                atk.AreaOfAffect.Center  += dir * atk.AreaOfAffect.Width / 2f;
                stage.InflictAttack(atk);
                //stage.PushEffect(new Effects.RectEffect(atk.AreaOfAffect as RectPoly));

                Effects.GraphicsEffect effect = MeleeAttack.CreateEffect(0.3f, target, atk.Period);
                if (effect != null)
                {
                    stage.PushEffect(effect);
                }
            }
        }