Beispiel #1
0
    // Use this for initialization
    void Awake()
    {
        heroA = heroAObject.GetComponent <HeroInterface>();
        heroB = heroBObject.GetComponent <HeroInterface>();

        //SetActivation();
    }
Beispiel #2
0
        public override bool MoveHero(HeroInterface Hero, AbstractField Previous)
        {
            if (NextInChain == null || Hero == null)
            {
                return(false);
            }
            if (!this.State.EnterField(this, Hero))
            {
                if (Previous != null)
                {
                    Previous.SetHero(Hero);
                }
                return(false);
            }

            Thread.Sleep(1000);

            this.Notify();

            this.Hero = null;

            if (Hero.IsDead())
            {
                Console.WriteLine("Field::Hero died");
                return(true);
            }
            else
            {
                return(this.NextInChain.MoveHero(Hero, this));
            }
        }
Beispiel #3
0
        //private bool WasActivated;
        public ObserverPassiveSkill(BattleController BattleController, Skill Skill, HeroInterface SkillOwner)
        {
            this.BattleController = BattleController;
            this.Skill            = Skill;
            this.SkillOwner       = SkillOwner;

            //this.WasActivated = false;
        }
Beispiel #4
0
 public override void SetHero(HeroInterface Hero = null)
 {
     this.Hero = Hero;
     if (Hero != null)
     {
         Hero.SetCoordinates(this.x, this.y);
     }
 }
        public override bool MoveHero(HeroInterface Hero, AbstractField Previous)
        {
            bool Result = false;

            if (Previous != null && Hero != null)
            {
                Previous.SetHero(Hero);
                Result = true;
            }
            return(Result);
        }
        public bool EnterField(Field Field, HeroInterface Hero)
        {
            if (!PermitEntry())
            {
                return(false);
            }
            if (Field.GetHero() != null)
            {
                return(false);
            }
            if (!Hero.PayActionCost(GetEntryCost()))
            {
                return(false);
            }
            Field.SetHero(Hero);

            return(true);
        }
        public void AddHero(HeroInterface Hero, int x, int y)
        {
            Field Field = GetField(x, y);

            if (Field != null)
            {
                this.Heroes.Add(Hero);
                Field.SetHero(Hero);

                List <Skill> PassiveSkills = Hero.GetAllPasiveSkills();
                foreach (Skill Skill in PassiveSkills)
                {
                    Hero.GetHealthStat().Register(ObserverFactory.GetInstance().RequestObserver(Skill, Hero), false);
                }

                Hero.GetHealthStat().Register(ObserverFactory.GetInstance().RequestObserver(Hero), true);
            }
        }
Beispiel #8
0
 public abstract bool MoveHero(HeroInterface Hero, AbstractField Previous);
 public override void Apply(HeroInterface hero)
 {
     ((HeroProxy)hero).damageResistance = this.DamageResistance;
 }
 public BattleScreenHeroHealthBar(HeroInterface Hero)
 {
     this.Hero = Hero;
 }
Beispiel #11
0
        public Observer RequestObserver(Skill Skill, HeroInterface OwningHero)
        {
            ObserverPassiveSkill Observer = new ObserverPassiveSkill(this.BattleController, Skill, OwningHero);

            return(Observer);
        }
 public Field GetField(HeroInterface Hero)
 {
     return(GetField(Hero.GetCoordinates()[0], Hero.GetCoordinates()[1]));
 }
 public override void Apply(HeroInterface hero)
 {
     ((HeroProxy)hero).damageVulnerability = this.DamageVulnerability;
 }
Beispiel #14
0
 public override void Apply(HeroInterface hero)
 {
     ((HeroProxy)hero).damageIncrease = this.DamageIncrease;
 }
 public override void SetHero(HeroInterface Hero)
 {
 }
Beispiel #16
0
 public abstract void SetHero(HeroInterface Hero = null);
Beispiel #17
0
 public CommandGather(HeroInterface GatheringHero)
 {
     this.GatheringHero = GatheringHero;
 }
Beispiel #18
0
        private void ReceiveCommands()
        {
            this.HeroQueue = this.Battlefield.GetAllHeroes();
            this.CommandStackNormal.Push(this.Battlefield.CreateMemento());
            this.RenderBattleField();

            String CommandInput;

            String[] Tokens;

            while (true)
            {
                CommandInput = Console.ReadLine();
                Tokens       = CommandInput.Split(' ');
                switch (Tokens[0])
                {
                case "move":
                    if (Tokens.Length != 2)
                    {
                        Console.WriteLine("Invalid syntax");
                        continue;
                    }
                    List <(int, int)> Coordinates = new List <(int, int)>();
                    int start_x = this.HeroQueue.First().GetCoordinates()[0];
                    int start_y = this.HeroQueue.First().GetCoordinates()[1];

                    if (Tokens[1].Split(',').Count() != 2)
                    {
                        Console.WriteLine("Invalid syntax");
                        continue;
                    }
                    int end_x = int.Parse(Tokens[1].Split(',')[0]);
                    int end_y = int.Parse(Tokens[1].Split(',')[1]);

                    int x_incerement = start_x < end_x ? 1 : -1;
                    int y_incerement = start_y < end_y ? 1 : -1;

                    int i = start_x;
                    int j = start_y;
                    while (i != end_x)
                    {
                        Coordinates.Add((i, j));
                        i += x_incerement;
                    }
                    while (j != end_y)
                    {
                        Coordinates.Add((i, j));
                        j += y_incerement;
                    }
                    Coordinates.Add((i, j));
                    Console.WriteLine(Coordinates.Count + " coordinates");

                    Command MoveCommand = new CommandMove(Coordinates);

                    lock (Refreshlock)
                    {
                        RefreshBattleField = true;
                        Monitor.PulseAll(Refreshlock);
                    }
                    this.ExecuteCommand(MoveCommand);
                    lock (Refreshlock)
                    {
                        RefreshBattleField = false;
                    }
                    Thread.Sleep(500);
                    this.RenderBattleField();
                    break;

                case "skill":
                    if (Tokens.Length != 3)
                    {
                        Console.WriteLine("Invalid syntax - need 3 params");
                        continue;
                    }

                    int SkillID = -1;
                    if (!int.TryParse(Tokens[1], out SkillID))
                    {
                        Console.WriteLine("Invalid syntax - param 1 must be integer");
                        continue;
                    }

                    Skill Skill = HeroQueue.First().GetSkill(SkillID);
                    if (Skill == null)
                    {
                        Console.WriteLine("Skill with id " + SkillID + " does not exist");
                        continue;
                    }

                    if (Skill.Passive)
                    {
                        Console.WriteLine("Cannot actively use passive skill");
                        continue;
                    }

                    ITriggerBehaviour TargetingStrategy = null;
                    switch (Tokens[2])
                    {
                    case "one":
                        TargetingStrategy = SelectOneTarget.GetInstance();
                        break;

                    case "auto":
                        TargetingStrategy = SelectAutoTarget.GetInstance();
                        break;

                    case "area":
                        TargetingStrategy = SelectArea.GetInstance();
                        break;

                    case "self":
                        TargetingStrategy = SelectSelf.GetInstance();
                        break;

                    default:
                        break;
                    }
                    if (TargetingStrategy == null)
                    {
                        Console.WriteLine("Invalid target strategy option");
                        continue;
                    }

                    Command UseSkillCommand = new CommandUseSkill(Skill, Battlefield.GetField(HeroQueue.First().GetCoordinates()[0], HeroQueue.First().GetCoordinates()[1]), TargetingStrategy);
                    this.ExecuteCommand(UseSkillCommand);
                    this.RenderBattleField();
                    break;

                case "gather":
                    Command GatherCommand = new CommandGather(this.HeroQueue.First());
                    this.ExecuteCommand(GatherCommand);
                    this.RenderBattleField();
                    break;

                case "end":
                    this.CommandStackNormal.Clear();
                    this.CommandStackNormal.Push(this.Battlefield.CreateMemento());
                    this.CommandStackReverse.Clear();

                    HeroInterface Temp = this.HeroQueue.First();
                    Temp.RestoreTurn();
                    this.HeroQueue.RemoveFirst();
                    this.HeroQueue.AddLast(Temp);

                    this.RenderBattleField();

                    break;

                case "undo":
                    if (this.CommandStackNormal.Count > 1)
                    {
                        this.CommandStackReverse.Push(this.CommandStackNormal.Pop());
                        this.Battlefield.Restore(this.CommandStackNormal.Peek());
                        this.RenderBattleField();
                    }
                    break;

                case "redo":
                    if (this.CommandStackReverse.Any())
                    {
                        this.CommandStackNormal.Push(this.CommandStackReverse.Pop());
                        this.Battlefield.Restore(this.CommandStackNormal.Peek());
                        this.RenderBattleField();
                    }
                    break;

                case "refresh":
                    this.RenderBattleField();
                    break;

                case "exit":
                    this.Over = true;
                    break;

                default:
                    Console.WriteLine("Unknown command");
                    break;
                }

                if (Over)
                {
                    lock (Refreshlock)
                    {
                        Monitor.PulseAll(Refreshlock);
                    }
                    break;
                }
            }

            ObserverFactory.GetInstance().Finish();
        }
Beispiel #19
0
        public Observer RequestObserver(HeroInterface Hero)
        {
            BattleScreenHeroHealthBar Observer = new BattleScreenHeroHealthBar(Hero);

            return(Observer);
        }
Beispiel #20
0
 public abstract void Apply(HeroInterface hero);