Exemple #1
0
        public virtual ISpecialAction NextSpecialAction()
        {
            if (next == null)
            {
                next = new WeaponUpgrade(new DoubleHookLauncher(SceneMgr, Owner));
            }

            return(next);
        }
        public virtual ISpecialAction NextSpecialAction()
        {
            if (next == null)
            {
                next = new WeaponUpgrade(new ProximityCannonII(SceneMgr, Owner));
            }

            return(next);
        }
        public virtual ISpecialAction NextSpecialAction()
        {
            if (next == null)
            {
                next = new WeaponUpgrade(new TargetingMineLauncher(SceneMgr, Owner));
            }

            return(next);
        }
        public void SwitchAction(ISpecialAction oldAction, ISpecialAction newAction)
        {
            WindowController c = windows.Find(w => w.Controller.Action == oldAction);

            c.Controller = new ActionControllerImpl(mgr, newAction);
            c.Window.AttachNewController(c.Controller);

            actions.Remove(oldAction);
            actions.Add(newAction);
        }
Exemple #5
0
        public List <IUnit> GetInsideTargets(Army first, ISpecialAction unit)
        {
            var victims = new List <IUnit>();
            int index   = first.IndexOf((IUnit)unit);

            int row = GetRow(first, (IUnit)unit);

            if (row == 0)
            {
                victims.Add(first[index + 1]);
                victims.Add(first[index + rowSize]);
                victims.Add(first[index + rowSize + 1]);
                if (index >= rowSize - 1)
                {
                    victims.Add(first[index - rowSize + 1]);
                }
                if (index >= rowSize)
                {
                    victims.Add(first[index - rowSize]);
                }
            }

            if (row == 1)
            {
                for (int i = 0; i < 4; i++)
                {
                    victims.Add(first[index + 1 + i]);
                    int j = index - 1 - i;
                    if (j >= 0)
                    {
                        victims.Add(first[j]);
                    }
                }
            }

            if (row == 2)
            {
                victims.Add(first[index + rowSize]);
                victims.Add(first[index + rowSize - 1]);
                if (index > rowSize)
                {
                    victims.Add(first[index - rowSize - 1]);
                }
                if (index > rowSize - 1)
                {
                    victims.Add(first[index - rowSize]);
                }
                if (index > 0)
                {
                    victims.Add(first[index - 1]);
                }
            }

            return(victims);
        }
Exemple #6
0
 public List <IUnit> GetTargets(Army first, Army second, ISpecialAction unit)
 {
     if (unit is BowmanUnit)
     {
         return(Strategy.GetOutsideTargets(first, second, unit));
     }
     else
     {
         return(Strategy.GetInsideTargets(first, unit));
     }
 }
 public SpectatorActionController(SceneMgr mgr, ISpecialAction action)
     : base(mgr, action)
 {
     if (action is ISpectatorAction)
     {
         this.spectatorAction = action as ISpectatorAction;
     }
     else
     {
         throw new Exception("Spectator action controller must be initated with Spectator action");
     }
 }
Exemple #8
0
        public List <IUnit> GetInsideTargets(Army inside, ISpecialAction unit)
        {
            var targets = new List <IUnit>();
            int index   = inside.IndexOf((IUnit)unit);
            int from    = (index - unit.Range > 0) ? index - unit.Range : 0;
            int to      = ((index + unit.Range + 1) > inside.Count()) ? inside.Count() : index + unit.Range + 1;

            for (int i = from; i < to; i++)
            {
                targets.Add(inside[i]);
            }
            return(targets);
        }
        protected override List<Unit> GetTargets(ISpecialAction specialUnit, List<Unit> allies, List<Unit> enemies)
        {
            Int32 specialUnitIndex = allies.FindIndex(unit => unit == specialUnit as Unit), targetIndex;
            List<Unit> targets = new List<Unit>();

            if (specialUnit.Target == ActionTarget.Any || specialUnit.Target == ActionTarget.Ally)
            {
                if (specialUnit.IsCompatibleType(specialUnit as Unit))
                    targets.Add(specialUnit as Unit);

                for (int i = 1; i < specialUnit.Range + 1; i++)
                {
                    targetIndex = specialUnitIndex - i;

                    if (targetIndex < 0)
                        break;

                    if (specialUnit.IsCompatibleType(allies[targetIndex]))
                        targets.Add(allies[targetIndex]);
                }

                for (int i = 1; i < specialUnit.Range + 1; i++)
                {
                    targetIndex = specialUnitIndex + i;

                    if (targetIndex > allies.Count - 1)
                        break;

                    if (specialUnit.IsCompatibleType(allies[targetIndex]))
                        targets.Add(allies[targetIndex]);
                }
            }

            if (specialUnit.Target == ActionTarget.Any || specialUnit.Target == ActionTarget.Enemy)
            {
                Int32 startingIndex = specialUnitIndex - specialUnit.Range;
                startingIndex = startingIndex > 0 ? startingIndex : 0;

                Int32 endingIndex = specialUnitIndex + specialUnit.Range;

                for (int i = startingIndex; i < Math.Min(enemies.Count, endingIndex + 1); i++)
                {
                    if (specialUnit.IsCompatibleType(enemies[i]))
                    {
                        targets.Add(enemies[i]);
                    }
                }
            }

            return targets;
        }
        protected void LoadFavAction()
        {
            if (owner.Statistics.Actions.Count == 0)
            {
                favAction = "No data";
                time      = 0;
                return;
            }

            ISpecialAction first = owner.Statistics.Actions.GroupBy(item => item).OrderByDescending(g => g.Count()).Select(g => g.Key).First();

            favAction = first.Name;
            time      = 0;
        }
Exemple #11
0
        public List <IUnit> GetOutsideTargets(Army first, Army second, ISpecialAction unit)
        {
            var targets   = new List <IUnit>();
            int indexUnit = first.IndexOf((IUnit)unit);

            if (indexUnit >= first.Count() - unit.Range)
            {
                int targetsCount = unit.Range - (first.Count() - 1 - indexUnit);
                for (int i = 0; i < ((targetsCount > second.Count())?second.Count():targetsCount); i++)
                {
                    targets.Add(second[second.Count() - 1 - i]);
                }
            }
            return(targets);
        }
Exemple #12
0
 private List <IUnit> GetTargets(IArmy first, IArmy second, ISpecialAction unitSpecial)
 {
     if (unitSpecial is Archer)
     {
         return(GameStrategy.GetTargetsForArcher(first, second, unitSpecial));
     }
     else if (unitSpecial is Infantry)
     {
         return(GameStrategy.GetTargetsForInfantry(first, unitSpecial));
     }
     else
     {
         return(GameStrategy.GetTargetsForHealer(first, unitSpecial));
     }
 }
Exemple #13
0
 public static void WriteSpecialAction(this NetOutgoingMessage msg, ISpecialAction action)
 {
     if (action is HealAction)
     {
         msg.Write(typeof(HealAction).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is ActiveWeapon)
     {
         msg.Write(typeof(ActiveWeapon).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is WeaponUpgrade)
     {
         msg.Write(typeof(WeaponUpgrade).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is AsteroidDamage)
     {
         msg.Write(typeof(AsteroidDamage).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is AsteroidGrowth)
     {
         msg.Write(typeof(AsteroidGrowth).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is AsteroidSlow)
     {
         msg.Write(typeof(AsteroidSlow).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is AsteroidThrow)
     {
         msg.Write(typeof(AsteroidThrow).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else if (action is StaticField)
     {
         msg.Write(typeof(StaticField).GUID.GetHashCode());
         action.WriteObject(msg);
     }
     else
     {
         msg.Write(0);
         Logger.Error("Sending unsupported action (" + action.Name + ")!");
     }
 }
Exemple #14
0
        public List <IUnit> GetOutsideTargets(Army inside, Army outside, ISpecialAction unit)
        {
            var targets = new List <IUnit>();
            int row     = (inside.Count() - inside.IndexOf((IUnit)unit) - 1) % rowSize;
            int line    = (inside.Count() - inside.IndexOf((IUnit)unit) - 1) / rowSize;

            if (line >= unit.Range)
            {
                return(targets);
            }
            for (int i = outside.Count() - 1 - row, targetsCount = unit.Range - line; i >= 0 && targetsCount > 0; i -= rowSize, targetsCount--)
            {
                targets.Add(outside[i]);
            }
            return(targets);
        }
Exemple #15
0
        public static List <ISpecialAction> ReadSpecialActions(this NetIncomingMessage msg, SceneMgr mgr)
        {
            int count = msg.ReadInt32();
            List <ISpecialAction> temp   = new List <ISpecialAction>();
            ISpecialAction        action = null;

            for (int i = 0; i < count; i++)
            {
                action = msg.ReadSpecialAction(mgr);
                if (action != null)
                {
                    temp.Add(action);
                }
            }

            return(temp);
        }
Exemple #16
0
        public static ISpecialAction ReadSpecialAction(this NetIncomingMessage msg, SceneMgr mgr, Player owner = null)
        {
            //chtelo by to aby kazdej objekt implementoval sendable takhle nektery akce nepujdou pouzit
            ISpecialAction action = null;
            int            hash   = msg.ReadInt32();

            if (hash == typeof(HealAction).GUID.GetHashCode())
            {
                action = new HealAction();
            }
            else if (hash == typeof(ActiveWeapon).GUID.GetHashCode())
            {
                action = new ActiveWeapon();
            }
            else if (hash == typeof(WeaponUpgrade).GUID.GetHashCode())
            {
                action = new WeaponUpgrade();
            }
            else if (hash == typeof(AsteroidDamage).GUID.GetHashCode())
            {
                action = new AsteroidDamage(mgr, owner);
            }
            else if (hash == typeof(AsteroidGrowth).GUID.GetHashCode())
            {
                action = new AsteroidGrowth(mgr, owner);
            }
            else if (hash == typeof(AsteroidSlow).GUID.GetHashCode())
            {
                action = new AsteroidSlow(mgr, owner);
            }
            else if (hash == typeof(AsteroidThrow).GUID.GetHashCode())
            {
                action = new AsteroidThrow(mgr, owner);
            }
            else if (hash == typeof(StaticField).GUID.GetHashCode())
            {
                action = new StaticField(mgr, owner);
            }

            if (action != null)
            {
                action.ReadObject(msg);
            }
            return(action);
        }
Exemple #17
0
        public List <IUnit> GetOutsideTargets(Army first, Army second, ISpecialAction unit)
        {
            var victims = new List <IUnit>();

            int row  = GetRow(first, (IUnit)unit);
            int line = GetLine(first, (IUnit)unit);

            if (line >= unit.Range)
            {
                return(victims);
            }

            for (int i = second.Count() - rowSize + row, victimsCount = unit.Range - line; i >= 0 && victimsCount > 0; i -= rowSize, victimsCount--)
            {
                victims.Add(second[i]);
            }
            return(victims);
        }
Exemple #18
0
        public List <IUnit> GetInsideTargets(Army inside, ISpecialAction unit)
        {
            var targets = new List <IUnit>();
            int index   = inside.IndexOf((IUnit)unit);

            int row  = (inside.Count() - index - 1) % rowSize;
            int line = (inside.Count() - index - 1) / rowSize;

            for (int i = 0; i < inside.Count(); i++)
            {
                int r = (inside.Count() - i - 1) % rowSize;
                int l = (inside.Count() - i - 1) / rowSize;
                if (Math.Sqrt((r - row) * (r - row) + (l - line) * (l - line)) <= unit.Range)
                {
                    targets.Add(inside[i]);
                }
            }
            return(targets);
        }
Exemple #19
0
 public void AddSharedAction(ISpecialAction a)
 {
     shared.Add(a);
 }
 public ActionController(ISpecialAction action, SceneMgr mgr)
 {
     sceneMgr = mgr;
     Action   = action;
 }
Exemple #21
0
 public void removeSharedAction(ISpecialAction a)
 {
     shared.Remove(a);
 }
 public ActionControllerImpl(SceneMgr mgr, ISpecialAction action)
     : base(action, mgr)
 {
 }
 protected abstract List<Unit> GetTargets(ISpecialAction specialUnit, List<Unit> allies, List<Unit> enemies);