Esempio n. 1
0
    private int OnUseCompleted(UseCompleted e)
    {
        Debug.Log("OnUseCompleted");
        DeselectUsableObject(e.objectUsed);

        UpdatePlayerMessage(e.pm);
        return(0);
    }
Esempio n. 2
0
    private int OnUsing(Using e)
    {
        if (Usable() == false)
        {
            e.valid = false;
            return(0);
        }


        timeRemaining -= e.dt;
        timeRemaining  = Math.Max(timeRemaining, 0.0f);

        float mu     = 1.0f - (timeRemaining / timeToComplete);
        float muStep = 1.0f / inProgressPMs.Length;
        //Debug.Log("mu:  " + mu);

        int sampleIndex = (int)((mu + (0.5f * muStep)) * ((float)inProgressPMs.Length - 1.0f));

        sampleIndex = Math.Min(sampleIndex, inProgressPMs.Length - 1);

        var pmToUse = inProgressPMs[sampleIndex];

        e.pm             = pmToUse;
        e.timeRemaining  = timeRemaining;
        e.timeToCompelte = timeToComplete;
        e.valid          = true;

        if (e.timeRemaining <= 0.0f)
        {
            UseCompleted uc = new UseCompleted();
            uc.objectUsed = gameObject;
            uc.pm         = UseCompletePM;
            FFMessageBoard <UseCompleted> .Send(uc, e.user);

            e.valid = false;
            Complete(e);
        }
        return(0);
    }