public void Activate()
 {
     if (baseNode != null)
     {
         baseNode.Activate();
     }
 }
    public void ActivateMagicCircle(bool shouldActivate)
    {
        MagicCircle mc = (MagicCircle)selectedUISN.linkedSpellNode;

        if (mc != null)
        {
            if (shouldActivate)
            {
                mc.Activate();
            }
            else
            {
                mc.Deactivate();
            }
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        rcvMsg = client.rcvMsg;
        if (msgList.Contains(rcvMsg) == false && rcvMsg != lastMsg)
        {
            if (rcvMsg.Substring(0, 1) == "s")
            {
                size = int.Parse(rcvMsg.Substring(1, 1));
            }
            msgList.Add(rcvMsg);
            lastMsg = rcvMsg;
            count++;
            if (count == size)
            {
                foreach (string msg in msgList)
                {
                    if (msg.Substring(0, 1) == "s")
                    {
                        valList.Add(msg.Substring(2, msg.Length - 2));
                    }
                    else
                    {
                        valList.Add(msg);
                    }
                }
                valList.Sort();
                string connected = "";
                foreach (string val in valList)
                {
                    connected += val.Substring(1, val.Length - 1).Trim();
                }
                valList.Clear();
                msgList.Clear();
                size  = 100;
                count = 0;

                string[] valArr    = connected.Split(',');
                int[]    parameter = new int[3] {
                    (int)int.Parse(valArr[0]) / 12, int.Parse(valArr[1]) / 2, int.Parse(valArr[2]) * 20
                };
                Debug.Log(parameter[0] + "," + parameter[1] + "," + parameter[2]);
                string base64 = valArr[3];
                mc.Activate(parameter, base64);
            }
        }
    }
    void FixedUpdate()
    {
        if (source != null && destination != null && source.IsMagicCircle() && destination.IsMagicCircle())
        {
            MagicCircle mcSource      = (MagicCircle)source;
            MagicCircle mcDestination = (MagicCircle)destination;
            if (mcSource.isActive != wasActivated)
            {
                wasActivated = mcSource.isActive;
                PendingOperation operation = mcSource.isActive ? PendingOperation.Activate : PendingOperation.Deactivate;
                pendingOpList.Add(new PendingOperationContainer(operation, delayTime));
                // timeTillActivate = delayTime;
                // pendingOperation = mcSource.isActive ? PendingOperation.Activate : PendingOperation.Deactivate;
            }
            // Timer to count down until you activate the magic circle
            List <int> removePoc = new List <int>();
            for (int i = 0; i < pendingOpList.Count; i++)
            {
                if (pendingOpList[i].timeTillOp <= 0)
                {
                    // Activate the magic
                    if (pendingOpList[i].pendingOp == PendingOperation.Activate)
                    {
                        mcDestination.Activate();
                    }
                    // Only Deactivate the magic if it hasn't already been deactivated
                    else if (mcDestination.isActive && pendingOpList[i].pendingOp == PendingOperation.Deactivate)
                    {
                        mcDestination.Deactivate();
                    }
                    removePoc.Add(i);
                }
                // Keep decreasing the time until it reaches 0;
                else
                {
                    pendingOpList[i].timeTillOp -= Time.fixedDeltaTime;
                }
            }
            for (int i = removePoc.Count - 1; i >= 0; i--)
            {
                pendingOpList.RemoveAt(i);
            }

            // if( timeTillActivate <= 0 )
            // {
            //     // Only Activate the magic if it hasn't already been activated
            //     if( !mcDestination.isActive && pendingOperation == PendingOperation.Activate )
            //     {
            //         mcDestination.Activate();
            //     }
            //     // Only Deactivate the magic if it hasn't already been activated
            //     else if( mcDestination.isActive &&  pendingOperation == PendingOperation.Deactivate )
            //     {
            //         mcDestination.Deactivate();
            //     }
            // }
            // // Keep decreasing the time until it reaches 0;
            // else
            // {
            //     timeTillActivate -= Time.fixedDeltaTime;
            // }
        }
        else
        {
            timeTillActivate = 0;
        }
    }