Exemplo n.º 1
0
    public override void SendToLocalGameObject(FFBasePacket package, GameObject go)
    {
        FFPacket <EventType> sentPackage = (FFPacket <EventType>)package;

        FFPacket <EventType> .Decrypt(ref sentPackage.message);

        switch (package.packetInstructions)
        {
        case FFPacketInstructionFlags.MessageBoardGameObjectSend:
            FFMessageBoard <EventType> .Send(sentPackage.message, go);

            break;

        case FFPacketInstructionFlags.MessageBoardGameObjectSendDown:
            FFMessageBoard <EventType> .SendDown(sentPackage.message, go);

            break;

        case FFPacketInstructionFlags.MessageBoardGameObjectSendUp:
            FFMessageBoard <EventType> .SendUp(sentPackage.message, go);

            break;

        case FFPacketInstructionFlags.MessageBoardGameObjectSendToAllConnected:
            FFMessageBoard <EventType> .SendAllConnected(sentPackage.message, go);

            break;

        default:
            break;
        }
    }
Exemplo n.º 2
0
    private void UpdateUse(float dt)
    {
        if (selectedObject != null)
        {
            //Debug.Log("Have Selected Object");
            if (Input.GetKeyDown(KeyCode.E))
            {
                //Debug.Log("UseBegin");

                UseBegin u = new UseBegin();
                u.user = gameObject;
                FFMessageBoard <UseBegin> .Send(u, selectedObject);
            }
            else if (Input.GetKey(KeyCode.E))
            {
                //Debug.Log("Using");

                Using u = new Using();
                u.user = gameObject;
                u.dt   = dt;
                FFMessageBoard <Using> .Send(u, selectedObject);

                if (u.valid)
                {
                    UpdatePlayerMessage(u.pm, 1.0f - (u.timeRemaining / u.timeToCompelte));
                }
            }
        }
        else
        {
            //Debug.Log("Don't Have selected Object");
        }
    }
Exemplo n.º 3
0
 void UseSelectedObject()
 {
     if (selectedObject != null)
     {
         UseBegin u = new UseBegin();
         u.user = gameObject;
         FFMessageBoard <UseBegin> .Send(u, selectedObject);
     }
 }
Exemplo n.º 4
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("OnTrigger Entered 2d");
        QueryUsable qu = new QueryUsable();

        FFMessageBoard <QueryUsable> .Send(qu, collision.gameObject);


        if (qu.usableObject)
        {
            SelectUsableObject(qu);
            DisplayUsableObjectMessage(qu);
        }
        else
        {
            DeselectUsableObject(qu.gameObject);
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (moving)
        {
            distance += Time.fixedDeltaTime * speed;

            var path = PathToFollow.GetComponent <FFPath>();

            if (distance > path.PathLength)
            {
                distance -= path.PathLength;
                ++loopCounter;
                if (loopCounter >= TimesToLoop)
                {
                    loopCounter = 0;
                    moving      = false;
                }
            }

            if (path)
            {
                var PrevPos    = path.PointAlongPath(distance - 0.01f);
                var position   = path.PointAlongPath(distance);
                var vecForward = Vector3.Normalize(position - PrevPos);

                transform.position = position;
                transform.up       = vecForward;

                if ((int)(distance / path.PathLength) > loopCounter)
                {
                    loopCounter = (int)(distance / path.PathLength);
                    PathFollowerCompletedLoopEvent e;
                    e.distTraveled = path.PathLength;
                    e.obj          = gameObject;
                    FFMessageBoard <PathFollowerCompletedLoopEvent> .Send(e, gameObject);
                }
            }
        }
    }
Exemplo n.º 6
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);
    }
Exemplo n.º 7
0
    void Complete(Using e)
    {
        Debug.Log("Completed: " + gameObject.name + " Usable Object");

        Static_Var.Money -= moneyCost;
        Static_Var.Money  = Mathf.Max(0, Static_Var.Money);

        ActivateUsableObject auo;

        auo.user = e.user;
        FFMessageBoard <ActivateUsableObject> .Send(auo, gameObject);

        foreach (var eff in effects)
        {
            if (BlackBoard.ContainsKey(eff) == false)
            {
                BlackBoard.Add(eff, true);
            }
        }

        ++timesUsed;

        if (advanced.ShowAtEnd)
        {
            HelpedYou help;
            help.obj = this.gameObject;
            FFMessage <HelpedYou> .SendToLocal(help);
        }


        if (advanced.LevelToLoadOnUseComplete != "")
        {
            TriggerFade tf;
            tf.level_name = advanced.LevelToLoadOnUseComplete;
            FFMessage <TriggerFade> .SendToLocal(tf);
        }
    }