示例#1
0
        public TUnit Add(string tdid)
        {
            TUnit ret = GMgr.GetUnit(tdid);

            AddToData(ret);
            return(ret);
        }
示例#2
0
        public TUnit Add(long rtid)
        {
            TUnit ret = GMgr.GetUnit(rtid);

            AddToData(ret);
            return(ret);
        }
示例#3
0
        public virtual TUnit SpawnNew(string id, Vector3?pos, Quaternion?quaternion = null)
        {
            TUnit temp = GMgr.SpawnNew(id, pos, quaternion);

            AddToData(temp);
            OnSpawned(temp);
            GMgr.Callback_OnUnitMgrAdded?.Invoke(temp);
            return(temp);
        }
    public override void Do(Actor fromActor, int _eventType)
    {
        base.Do(fromActor, _eventType);


        // GameManager.Instance.RemoveActor(ref a);
        int whichActor = 0;


        // Remove Actor N given by method inputs

        // Get which actor should be removed
        switch (base.InputLocations[0])
        {
        case MethodVariableLocation.Constants:
            if (InputLocationNumbers[0] < Constants.Count)
            {
                whichActor = (int)Constants[InputLocationNumbers[0]];
            }
            break;

        case MethodVariableLocation.CallingActor:
            if (InputLocationNumbers[0] < fromActor.FVariables.Count)
            {
                whichActor = (int)fromActor.FVariables[InputLocationNumbers[0]];
            }
            break;

        case MethodVariableLocation.Global:
            if (InputLocationNumbers[0] < GMgr.FVariables.Count)
            {
                whichActor = (int)GMgr.FVariables[InputLocationNumbers[0]];
            }
            break;

        default:
            base.TimesInvalidInputLocationChosen++;
            return;

            break;
        }


        // If output location is specified, this rules over previous (ie. calling removes the calling actor, other or global removes by id)6U4Rlbgrdutuieklhrvtuelfiunvbdrn

        if (whichActor >= 0 && whichActor < GMgr.Actors.Count)
        {
            // Remove that actor
            GMgr.RemoveActor(whichActor);
        }
        else
        {
            TimesNonExistantActorReferenced++;
        }
    }
示例#5
0
 public virtual void Despawn(TUnit unit)
 {
     if (unit == null)
     {
         CLog.Error("unit 为 null");
         return;
     }
     if (!Data.ContainsValue(unit))
     {
         return;
     }
     RemoveFromData(unit);
     GMgr.Despawn(unit);
     GMgr.Callback_OnUnitMgrRemoved?.Invoke(unit);
 }
示例#6
0
    public override void Do(Actor fromActor, int _eventType)
    {
        base.Do(fromActor, _eventType);


        float dir = -1;

        switch (InputLocations[0])
        {
        case MethodVariableLocation.Constants:
            if (InputLocationNumbers[0] > 0 && InputLocationNumbers[0] < Constants.Count)
            {
                dir = Constants[InputLocationNumbers[0]];
            }
            break;

        case MethodVariableLocation.CallingActor:
            if (InputLocationNumbers[0] > 0 && InputLocationNumbers[0] < GlobalConstants.ActorNumReadableVariables)
            {
                dir = fromActor.FVariables[InputLocationNumbers[0]];
            }
            break;

        case MethodVariableLocation.Global:
            if (InputLocationNumbers[0] > 0 && InputLocationNumbers[0] < GlobalConstants.GlobalNumReadableVariables)
            {
                dir = GMgr.FVariables[InputLocationNumbers[0]];
            }
            break;

        default:
            break;
        }

        // Common sense movement if from human input
        switch (_eventType)
        {
        case ActorEvent.KeyW:
            dir = MovementDirection.N;
            break;

        case ActorEvent.KeyA:
            dir = MovementDirection.W;
            break;

        case ActorEvent.KeyS:
            dir = MovementDirection.S;
            break;

        case ActorEvent.KeyD:
            dir = MovementDirection.E;
            break;

        default:
            // Do nothing
            break;
        }

        Debug.Log(string.Format("Movement/Do: Moving actor #{0} in direction {1}", fromActor.ID, dir));

        GMgr.MoveActor(fromActor.ID, dir);
    }
    public override void Do(Actor fromActor, int _eventType)
    {
        base.Do(fromActor, _eventType);

        GMgr.EndGame();
    }
    public override void Do(Actor fromActor, int _eventType)
    {
        // First input is actor blueprint
        // Second input is vector for location
        // Third input is the other actor
        base.Do(fromActor, _eventType);


        int     BlueprintToSpawn = -1;
        Vector2 Loc = new Vector2();


        // Get which actor should be spawned
        switch (base.InputLocations[0])
        {
        case MethodVariableLocation.Constants:
            if (InputLocationNumbers[0] < Constants.Count)
            {
                BlueprintToSpawn = (int)Constants[InputLocationNumbers[0]];
            }
            break;

        case MethodVariableLocation.CallingActor:
            if (InputLocationNumbers[0] < fromActor.FVariables.Count)
            {
                BlueprintToSpawn = (int)fromActor.FVariables[InputLocationNumbers[0]];
            }
            break;

        case MethodVariableLocation.Global:
            if (InputLocationNumbers[0] < GMgr.FVariables.Count)
            {
                BlueprintToSpawn = (int)GMgr.FVariables[InputLocationNumbers[0]];
            }
            break;

        default:
            base.TimesInvalidInputLocationChosen++;
            return;

            break;
        }

        switch (InputLocations[1])
        {
        case MethodVariableLocation.Constants:
            if (Constants.Count > 0)
            {
                // Get location from 3 float variables in method constants. Cycle through, so inputlocations[1] decides first, the
                //  next is at inputlocations[1] + 1   and then we use modulus, in case we go out of bounds
                Loc = new Vector2(Constants[InputLocationNumbers[1] % GlobalConstants.MethodConstantCount],
                                  Constants[(InputLocationNumbers[1] + 1) % GlobalConstants.MethodConstantCount]);
            }
            break;

        case MethodVariableLocation.CallingActor:
            if (InputLocationNumbers[1] < fromActor.VVariables.Count)
            {
                Loc = fromActor.VVariables[InputLocationNumbers[1]];
            }
            break;

        case MethodVariableLocation.Global:
            if (InputLocationNumbers[1] < GMgr.VVariables.Count)
            {
                Loc = GMgr.VVariables[InputLocationNumbers[1]];
            }
            break;

        default:
            base.TimesInvalidInputLocationChosen++;
            return;

            break;
        }

        GMgr.AddActor(BlueprintToSpawn, Loc);
    }