Example #1
0
        public void Cast(SpellCard spell, Container target)
        {
            var Mana = Container.GetComponent <Mana>();

            if (Mana == null)
            {
                throw new ArgumentException("No mana in container");
            }
            if (spell == null)
            {
                throw new ArgumentNullException(nameof(spell));
            }
            if (!SpellCards.Contains(spell))
            {
                throw new ArgumentException("It is'not my spell");
            }

            if (Mana.Value < spell.GetComponent <Cost>().Value)
            {
                throw new ArgumentException("Low mana");
            }

            Mana.DeltaMana(-spell.GetComponent <Cost>().Value);
            spell.GetComponent <Spell>().Use(target);

            if (OnSpellCast != null)
            {
                OnSpellCast.Invoke(new SessionChange()); //TODO
            }
        }
Example #2
0
        public void CastSolider(SoliderCard solider, Position position)
        {
            if (position.CompareTo(Container.Session.Map.Size) >= 0)
            {
                throw new ArgumentException("Too big position");
            }
            var f = Container.Session.Map.FindByPosition(position);

            if (f.Positioned != null)
            {
                throw new ArgumentException("Another target already in this position");
            }
            var Mana = Container.GetComponent <Mana>();

            if (Mana == null)
            {
                throw new ArgumentException("No mana in container");
            }
            if (solider == null)
            {
                throw new ArgumentNullException(nameof(solider));
            }
            if (!Soliders.Remove(solider))
            {
                throw new ArgumentException("It is'not my spell");
            }

            if (Mana.Value < solider.GetComponent <Cost>().Value)
            {
                throw new ArgumentException("Low mana");
            }
            Mana.DeltaMana(-solider.GetComponent <Cost>().Value);

            solider.SetOwner(Container.Owner);
            solider.GetComponent <Positionable>().Position   = position;
            solider.GetComponent <Positionable>().Positioned = true;

            if (OnSoliderCasted != null)
            {
                OnSoliderCasted.Invoke(new SessionChange()); //TODO
            }
        }
Example #3
0
        public void Attack(Container target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }
            Destroyable destr;

            if ((destr = target.GetComponent <Destroyable>()) == null)
            {
                throw new ArgumentException("target have'nt Destroyable component");
            }

            if (OnAttack != null)
            {
                OnAttack.Invoke(new SessionChange()); //TODO
            }
            int attackPower = this.attackPower;

            destr.DeltaHealth(-attackPower);
        }