public void AcceptsAcceptableInput()
        {
            var state = new ScriptableState();

            state.Screen = null;
            state.RegisterClick(0, 0, 10, 10, new ScriptableState());
        }
 private void AddUniqueState(ScriptableState state, List <ScriptableState> list)
 {
     if (!list.Contains(state))
     {
         list.Add(state);
     }
 }
Example #3
0
 public void ChangeState(ScriptableState newState)
 {
     currentState.OnExitState(this);
     newState.OnEnterState(this);
     currentState = newState;
     sinceState   = Time.time;
     Debug.Log("Entering state " + newState.name);
 }
        public StateNode(Vector2 position, Type stateIdType, int nodeId, ScriptableState stateAsset = null, object stateId = null)
        {
            _nodeRect = new Rect(position.x, position.y, Width, Height);
            NodeId    = nodeId;

            _controlsAreaStyle         = new GUIStyle();
            _controlsAreaStyle.padding = new RectOffset(ControlPaddingLeft, ControlPaddingRight, ControlPaddingTop, ControlPaddingBottom);

            _identityTitleStyle           = new GUIStyle();
            _identityTitleStyle.padding   = new RectOffset(20, 20, 20, 20);
            _identityTitleStyle.alignment = TextAnchor.MiddleCenter;
            _identityTitleStyle.fontSize  = 20;
            _identityTitleStyle.wordWrap  = true;

            _stateIdDrawer = PlainStateMachineGenericTypeDrawerFactory.Create(stateIdType, stateId);

            AsNormal();
        }
Example #5
0
    public void Tick()
    {
        ScriptableState currentState      = unit.GetState();
        List <string>   availableCommands = currentState.GetCommandsList();
        Unit            u = CanShotAnyone();

        if (u != null)
        {
            if (availableCommands.Contains("Aim"))
            {
                currentOrder = "apunten";
                point        = u.transform.position;
            }
            else if (availableCommands.Contains("Fire"))
            {
                currentOrder = "disparen";
                point        = u.transform.position;
            }
            else if (availableCommands.Contains("Wait"))
            {
                currentOrder = "esperen";
            }
        }
        else
        {
            Unit nearest = Nearest();
            if (nearest != null)
            {
                if (availableCommands.Contains("Move"))
                {
                    currentOrder = "muévanse";
                }
                else if (availableCommands.Contains("Here"))
                {
                    currentOrder = "aquí";
                    point        = nearest.transform.position;
                }
                else if (availableCommands.Contains("Wait") && u != null)
                {
                    currentOrder = "esperen";
                }
            }
        }
    }
Example #6
0
    public void Init(IUnitInput i, UnitData d, List <Soldier> s, Unit u)
    {
        actions   = new Dictionary <string, UnityAction <string> >();
        input     = i;
        data      = d;
        soldiers  = s;
        unit      = u;
        selected  = false;
        unselect += Unselect;

        if (!unit.isAi)
        {
            unitNumber = ++UNIT_NUMBERS;
            unit.ChangeUnitNumber(unitNumber.ToString());
        }

        actions.Add(data.UnitName, Select);
        foreach (var action in Alias.GetWords())
        {
            if (Alias.GetOrder(action) == data.UnitName)
            {
                actions.Add(action, Select);
            }
            else if (action == "uno" || action == "dos" || action == "tres" || action == "cuatro" || action == "cinco" || action == "seis" || action == "siete" || action == "ocho" || action == "nueve")
            {
                actions.Add(action, Subselect);
            }
            else
            {
                actions.Add(action, Message);
            }
        }

        /*actions.Add("para", Message);
        *  actions.Add("esperen", Message);
        *  actions.Add("moveos", Message);
        *  actions.Add("aquí", Message);*/

        InitController();
        input.Init(actions, data, u);

        currentState = data.FirstState;
    }
Example #7
0
    public void Tick()
    {
        ScriptableState currentState      = unit.GetState();
        List <string>   availableCommands = currentState.GetCommandsList();
        bool            canEngage         = CanEngage();
        bool            engaged           = unit.GetEngaged() != null;

        timer += Time.deltaTime;
        if (availableCommands.Contains("Attack") && canEngage == true && !engaged)
        {
            currentOrder = "ataquen";
        }
        else
        {
            Unit nearest = Nearest();
            if (CheckAngle(unit.unitData, unit.transform, nearest.transform.position) && Vector3.Distance(unit.transform.position, nearest.transform.position) < 20f && availableCommands.Contains("Charge"))
            {
                currentOrder = "carguen";
            }
            else if (!CheckAngle(unit.unitData, unit.transform, nearest.transform.position) || !CheckDistance(unit.unitData, unit.transform, nearest.transform.position) && availableCommands.Contains("Move"))
            {
                currentOrder = "muévanse";
            }
            else if (availableCommands.Contains("Move"))
            {
                currentOrder = "muévanse";
            }
            else if (availableCommands.Contains("Here"))
            {
                currentOrder = "aquí";
                point        = nearest.transform.position;
                timer        = 0f;
            }
            else if (timer >= changeDestinationTime && availableCommands.Contains("Wait") && !engaged)
            {
                currentOrder = "esperen";
            }
        }
    }
        public void AddNode(Vector2 mousePosition, ScriptableState stateObject = null)
        {
            var newNode = new StateNode(mousePosition, _builder.StateIdType, GenerateStateNodeId(), stateObject);

            InternalAddNode(newNode);
        }