Exemplo n.º 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);
    }
Exemplo n.º 2
0
    protected virtual BaseUnit onCreateUnit(RemoteEventBase theEvent)
    {
        Logger.firebase("Humanoid onRemoteUpdate not find " + theEvent.getActorId());
        Logger.firebase("Humanoid onRemoteCreate +" + " " + theEvent.getActorId());
        BaseUnit temp = null;

        if (unitInstances.TryGetValue(theEvent.getActorId(), out temp))
        {
            Logger.firebase("Humanoid onRemoteCreate fail due to exist +" + " " + theEvent.getActorId());
            return(null);
        }
        GameObject obj = Instantiate(myUnits[0], convertLocationByHumanoid(theEvent.getCurrentLocation()), Quaternion.identity) as GameObject;

        obj.transform.parent = gameController.transform;
        BaseUnit unit = obj.GetComponent <BaseUnit>();

        unit.setGameController(gameController);
        unit.Myfaction      = getHumanoidFaction();
        unit.Id             = theEvent.getActorId();
        unit.playerIdOfUnit = theEvent.getPlayerId();
        unit.setHumanoidHolder(this);
        unitInstances.Add(unit.Id, unit);

        onMoveUnit(theEvent, unit);

        return(unit);
    }
Exemplo n.º 3
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();
    }
Exemplo n.º 4
0
 protected virtual void onMoveUnit(RemoteEventBase theEvent, BaseUnit unit)
 {
     unit.gameObject.transform.localPosition = convertLocationByHumanoid(theEvent.getCurrentLocation());
     unit.nextLocation = convertLocationByHumanoid(theEvent.getTargetLocation());
     unit.BeCommanded  = true;
 }