コード例 #1
0
    public static void setBattleEventValue(IFirebase refFirebase, RemoteEventBase theEvent)
    {
        Dictionary <string, object> currentlocatoin = new Dictionary <string, object>();

        currentlocatoin.Add(RemoteEventBase.KEY_VECTOR_X, theEvent.getCurrentLocation().x);
        currentlocatoin.Add(RemoteEventBase.KEY_VECTOR_Y, theEvent.getCurrentLocation().y);
        currentlocatoin.Add(RemoteEventBase.KEY_VECTOR_Z, theEvent.getCurrentLocation().z);

        Dictionary <string, object> targetlocation = new Dictionary <string, object>();

        targetlocation.Add(RemoteEventBase.KEY_VECTOR_X, theEvent.getTargetLocation().x);
        targetlocation.Add(RemoteEventBase.KEY_VECTOR_Y, theEvent.getTargetLocation().y);
        targetlocation.Add(RemoteEventBase.KEY_VECTOR_Z, theEvent.getTargetLocation().z);

        Dictionary <string, object> value = new Dictionary <string, object>();

        value.Add(RemoteEventBase.KEY_ACTION_NAME, theEvent.getActionName());
        value.Add(RemoteEventBase.KEY_ACTOR, theEvent.getActorId());
        value.Add(RemoteEventBase.KEY_ACT_TARGET, theEvent.getActTarget());
        value.Add(RemoteEventBase.KEY_PLAYER_ID, theEvent.getPlayerId());

        value.Add(RemoteEventBase.KEY_LOC_CURRENT, currentlocatoin);
        value.Add(RemoteEventBase.KEY_LOC_TARGET, targetlocation);
        value.Add(RemoteEventBase.KEY_TIME_STAMP, theEvent.getTimeStamp());

        refFirebase.Child(RemoteEventBase.KEY_EVENT_ROOT).Push().SetValue(value);
    }
コード例 #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        lock (mylock)
        {
            foreach (System.Object o in toCreateList)
            {
                copyToCreateList.Add(o);
            }
            toCreateList.Clear();
        }


        foreach (System.Object o in copyToCreateList)
        {
            RemoteEventBase todoEvent = (RemoteEventBase)o;

            Debug.Log("Humanoid onRemoteCreate +" + " " + todoEvent.getEventId() + " " + todoEvent.getCurrentLocation().y);
            onCreateUnit(todoEvent);
        }
        copyToCreateList.Clear();


        lock (unitlock)
        {
            foreach (System.Object o in toUpdateList)
            {
                copyToUpdateList.Add(o);
            }
            toUpdateList.Clear();
        }

        foreach (System.Object o in copyToUpdateList)
        {
            RemoteEventBase todoEvent = (RemoteEventBase)o;

            BaseUnit result = null;
            if (unitInstances.TryGetValue(todoEvent.getActorId(), out result))
            {
                Logger.firebase("Humanoid onRemoteUpdate find " + todoEvent.getActorId() + ", " + todoEvent.getCurrentLocation().y + ", " + gameObject.transform.localPosition.y + ", " + todoEvent.getTargetLocation().y);

                onMoveUnit(todoEvent, result);
            }
            else
            {
                Logger.firebase("Humanoid onRemoteUpdate not find " + todoEvent.getActorId());

                onCreateUnit(todoEvent);
            }
        }
        copyToUpdateList.Clear();

        onFixedUPdate();
    }
コード例 #3
0
 protected virtual void onMoveUnit(RemoteEventBase theEvent, BaseUnit unit)
 {
     unit.gameObject.transform.localPosition = convertLocationByHumanoid(theEvent.getCurrentLocation());
     unit.nextLocation = convertLocationByHumanoid(theEvent.getTargetLocation());
     unit.BeCommanded  = true;
 }