public void Load(JObject data)
        {
            name = (string)data["name"];
            // Load experience first because maybe that will affect equipment legality?
            if (experience != null)
            {
                experience.Load(data.Value <JObject>("experience"));
            }

            activePowers.Clear();

            // set active powers
            foreach (string powerName in data["activePowers"])
            {
                Powers activatedPower = classInfo.classPowers.Find(p => Utility.TrimCloned(p.name) == powerName);
                if (activatedPower != null)
                {
                    activePowers.Add(activatedPower);
                }
                else
                {
                    //maybe throw?
                    throw new System.ArgumentException("Power not found");
                }
            }
            if (activePowers.Count < 1)
            {
                throw new System.ArgumentException("No active powers");
                // maybe instead pick the first one?
            }

            weapon.Load((string)data["weapon"]);
            ringL.Load((string)data["ringL"]);
            ringR.Load((string)data["ringR"]);
        }
        public override void AddAttack(List <Character> targets, List <Character> allies)
        {
            //HACK maybe drag powers into behaviour?
            Powers reloadPower = chara.classInfo.classPowers.Find((Powers p) => { return(p.powName == reloadName); });
            Powers arrowPower  = chara.classInfo.classPowers.Find((Powers p) => { return(p.powName == arrowName); });

            if (reloadPower == null || arrowPower == null)
            {
                Debug.LogWarning(chara.name + " does not have required powers for ArcherBehaviour");
                AttackRandomFallback(targets, allies);
            }
            else
            {
                int       targetIndex = Random.Range(0, targets.Count);
                Character target      = targets[targetIndex];
                chara.target = target.gameObject;
                if (loaded)
                {
                    GetTurnBehaviour().turnAddAttackEnemy(arrowPower, chara);
                    loaded = false;
                }
                else
                {
                    GetTurnBehaviour().turnAddAttackEnemy(reloadPower, chara);
                    loaded = true;
                }
            }
        }
Beispiel #3
0
        public void SetPower(Powers pow, GameObject button, Character chara)
        {
            power     = pow;
            character = chara;
            Btn       = button.GetComponent <Button>();
            Name      = button.GetComponentInChildren <Text>();

            if (power != null && Btn != null)
            {
                if (Icon != null)
                {
                    Icon.sprite = power.icon;
                }
                if (Name != null)
                {
                    Name.text = power.powName;
                    if (Btn.GetComponentInChildren <Text>().text != null)
                    {
                    }
                }

                //hooking up button to event
                Btn.onClick.AddListener(() => HandleClick());
            }
        }
Beispiel #4
0
        protected void AttackRandomFallback(List <Character> targets, List <Character> allies)
        {
            int       targetIndex = Random.Range(0, targets.Count);
            Character target      = targets[targetIndex];

            chara.target = target.gameObject;
            int    powerIndex = Random.Range(0, chara.classInfo.classPowers.Count);
            Powers powers     = chara.classInfo.classPowers[powerIndex];

            GetTurnBehaviour().turnAddAttackEnemy(powers, chara);
        }
 //seperates out enemy movement turns from player
 public void turnAddAttackEnemy(Powers pow, Character chara)
 {
     if (numOfEnemyTurns > 0)
     {
         TurnInfo tmp;
         tmp.ability = pow;
         tmp.player  = chara;
         numOfEnemyTurns--;
         MovesThisRound.Add(tmp);
     }
 }
Beispiel #6
0
 // Checks powers are the same
 // Currently just checks powName, maybe should check name instead?
 public override bool Equals(object other)
 {
     if (other.GetType() == this.GetType())
     {
         Powers otherPower = other as Powers;
         return(otherPower.powName == this.powName);
     }
     else
     {
         return(false);
     }
 }
 // add power to list of available powers
 public void AddPower(Powers power)
 {
     // Check if power already in list
     if (!classInfo.classPowers.Exists(p => p.Equals(power)))
     {
         // Add new instance of power to list
         classInfo.classPowers.Add(Instantiate(power));
     }
     else
     {
         Debug.LogWarning("Power " + power.powName + " could not be added as it already exists in list.");
     }
 }
 public bool ActivatePower(Powers power)
 {
     // Check there aren't too many powers on
     // Then, if power is in classInfo, and not in ActivePowers, add to ActivePowers
     if (activePowers.Count < Character.maxActivePowers &&
         classInfo.classPowers.Contains(power) &&
         !activePowers.Contains(power))
     {
         activePowers.Add(power);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        //creates temp struct to hold passed in values then adds this to the list of moves
        public void TurnAddAttack(Powers pow, Character chara)
        {
            if (numOfTurns > 0)
            {
                TurnInfo tmp;
                tmp.ability = pow;
                tmp.player  = chara;
                numOfTurns--;

                RemoveAttack(tmp);
                MovesThisRound.Add(tmp);

                //decal stuff
                manager.AddDecal(chara);
                contUi.SetInteractable();
            }
        }
        public override void AddAttack(List <Character> targets, List <Character> allies)
        {
            float     maxDamage  = float.MinValue;
            Powers    bestPower  = null;
            Character bestTarget = null;

            foreach (Character target in targets)
            {
                foreach (Powers power in chara.classInfo.classPowers)
                {
                    float damage = power.CalculateDamage(chara, target);
                    if (damage > maxDamage)
                    {
                        maxDamage  = damage;
                        bestPower  = power;
                        bestTarget = target;
                    }
                }
            }
            chara.target = bestTarget.gameObject;
            GetTurnBehaviour().turnAddAttackEnemy(bestPower, chara);
        }
Beispiel #11
0
 public bool DeactivatePower(Powers power)
 {
     return(activePowers.Remove(power));
 }