コード例 #1
0
    public override void Pick(PlanOfAttack finalPlan)
    {
        PlanOfAttack optionalPlan = new PlanOfAttack();
        PlanOfAttack plan         = new PlanOfAttack();

        for (int i = 0; i < pickers.Count; i++)
        {
            BaseAbilityPicker p = pickers[i];
            p.Pick(plan);
            cp.Evaluate(plan);
            if (plan.ability == null)
            {
                optionalPlan = plan;
                continue;
            }
            Debug.Log(plan.ability.name);
            Debug.Log(plan.unit.name);
            string    unit    = plan.unit.name;
            string    ability = plan.ability.name;
            Unit.Pair pair    = new Unit.Pair(unit, ability);
            if (owner.pairings.Contains(pair))
            {
                pair = (Unit.Pair)owner.pairings[owner.pairings.IndexOf(pair)];
            }
            else
            {
                owner.pairings.Add(pair);
                max         = pair.damage;
                abilityName = pair.ability;
            }
            if (pair.damage >= max)
            {
                max                       = pair.damage;
                abilityName               = pair.ability;
                finalPlan.ability         = plan.ability;
                finalPlan.target          = plan.target;
                finalPlan.moveLocation    = plan.moveLocation;
                finalPlan.fireLocation    = plan.fireLocation;
                finalPlan.attackDirection = plan.attackDirection;
                finalPlan.unit            = plan.unit;
            }
            bmc.Display("Current max: " + max + " by " + abilityName);
            StartCoroutine(Wait());
        }
        max = 0;
        if (finalPlan.ability == null)
        {
            finalPlan.ability         = optionalPlan.ability;
            finalPlan.target          = optionalPlan.target;
            finalPlan.moveLocation    = optionalPlan.moveLocation;
            finalPlan.fireLocation    = optionalPlan.fireLocation;
            finalPlan.attackDirection = optionalPlan.attackDirection;
            finalPlan.unit            = optionalPlan.unit;
        }
        finalPlan.complete = true;
    }
コード例 #2
0
    protected override int OnApply(Tile target)
    {
        Unit defender = target.content.GetComponent <Unit>();

        // Start with the predicted damage value
        int value = Predict(target);

        // Add some random variance
        value = Mathf.FloorToInt(value * UnityEngine.Random.Range(0.9f, 1.1f));

        // Clamp the damage to a range
        value = Mathf.Clamp(value, minDamage, maxDamage);

        // Apply the damage to the target
        Stats s = defender.GetComponent <Stats>();

        s[StatTypes.HP] += value;
        StartCoroutine(Wait());
        GetComponentInParent <Unit>().bmc.Display(GetComponentInParent <Unit>().name + " inflicted " + Math.Abs(value) + " points of damage to " + defender.name);
        string abilityName = transform.parent.name;
        string targetName  = defender.name;

        Unit.Pair pair = new Unit.Pair(targetName, abilityName);
        pair.damage = Math.Abs(value);
        int index = GetComponentInParent <Unit>().pairings.IndexOf(pair);

        if (index >= 0)
        {
            GetComponentInParent <Unit>().pairings.RemoveAt(index);
            GetComponentInParent <Unit>().pairings.Add(pair);
        }
        else
        {
            GetComponentInParent <Unit>().pairings.Add(pair);
        }
        return(value);
    }