示例#1
0
    public override void applyEffect(Person owner, Person target, float startTime, Ability ab)
    {
        var clonePerson = (Person)person.Clone();

        clonePerson.summoner = owner;
        clonePerson.id       = PersonFactory.getNextId();

        var e = new SummonEvent();

        e.owner     = owner;
        e.target    = target;
        e.person    = clonePerson;
        e.eventTime = startTime;
        EventQueueSingleton.queue.add(e);

        if (duration > 0)
        {
            var removeEvent = new RemoveSummonEvent();
            removeEvent.owner     = owner;
            removeEvent.target    = target;
            removeEvent.person    = clonePerson;
            removeEvent.eventTime = startTime + duration;
            EventQueueSingleton.queue.add(removeEvent);
        }
    }
    private void TryToSummon( )
    {
        // Pick new event if we have non
        if (nextSummonEventToPlay == null)
        {
            nextSummonEventToPlay = PickNextSummonEvent( );
        }

        // Do we have enough mana?
        if (nextSummonEventToPlay.SummonCost > mana)
        {
            return;
        }

        if (CheatAndDebug.Instance.ShowDebugInfo)
        {
            string s = "";
            foreach (var u in nextSummonEventToPlay.Instances)
            {
                s += $"{u.name} ";
            }
            Debug.Log($"Summoning: {s}");
        }

        // Start summoning
        StartCoroutine(SummonEvent(nextSummonEventToPlay));
        nextSummonEventToPlay = null;
    }
    private IEnumerator SummonEvent(SummonEvent summonEvent)
    {
        mana -= nextSummonEventToPlay.SummonCost;
        manaCounterLabel.text = mana.ToString("0");

        // Summon every unit included in the event
        foreach (var instance in summonEvent.Instances)
        {
            StartCoroutine(SummonUnit(instance, GetRandomPoint( )));

            yield return(new WaitForSeconds(delayBetweenSummonsInOneEvent));              // So the units aren't summoned all at the same time
        }
    }
示例#4
0
 public void OnDestroy()
 {
     SummonSuccess = null;
 }
    private SummonEvent PickNextSummonEvent( )
    {
        SummonEvent summonEvent = null;

        // Summon events that meet the requirements
        var validChoices = summonEvents.Where(e => enrageMeter >= e.EnrageMin && enrageMeter <= e.EnrageMax).ToList( );

        if (CheatAndDebug.Instance.ShowDebugInfo)
        {
            string s = "Valid Choices: ";
            foreach (var item in validChoices)
            {
                s += "[";
                foreach (var u in item.Instances)
                {
                    s += $"{u.name} ";
                }
                s += "] ";
            }
            Debug.Log(s);
        }

        // Sum of all valid choices' weights
        float weightSum = 0;

        foreach (var item in validChoices)
        {
            weightSum += item.Weight;
        }

        float weigthPoint = Random.Range(0, weightSum);

        if (CheatAndDebug.Instance.ShowDebugInfo)
        {
            Debug.Log($"weightSum: {weightSum}, weigthPoint: {weigthPoint}");
        }

        // Pick a random event from all the valid ones
        // using weights - that way some have more probability to appear then others
        weightSum = 0;
        foreach (var item in validChoices)
        {
            weightSum += item.Weight;
            if (weightSum >= weigthPoint)
            {
                // Found next summon event
                summonEvent = item;
                if (CheatAndDebug.Instance.ShowDebugInfo)
                {
                    string s = "Next Event: ";
                    foreach (var u in item.Instances)
                    {
                        s += $"{u.name} ";
                    }
                    Debug.Log(s);
                }
                break;
            }
        }

        return(summonEvent);
    }