Example #1
0
    // Update is called once per frame
    void LateUpdate()
    {
        current_state.update(this);
        if (char_type == CharType.NPC || char_type == CharType.NPC_Melee)
        {
            //Debug.Log (root.get_path ());
            if (!root.IsActive)
            {
                root.Activate(gameObject);
            }
            root.Update(0, gameObject);
        }

        rigid.MovePosition(rigid.position + (Vector2)(move_direction * speed * Time.deltaTime));

        if (walk_progress < 1.0f)
        {
            walk_progress += (Time.deltaTime * speed) / length;
            rigid.MovePosition(Vector3.Lerp(start_position, walk_target, Mathf.Clamp01(walk_progress)));
            target(walk_target);
        }

        float axis_input = Input.GetAxis("Mouse ScrollWheel");

        if (Mathf.Abs(axis_input) > 0)
        {
            weapons [selected_weapon].gameObject.SetActive(false);
            selected_weapon = (selected_weapon + (int)Mathf.Sign(axis_input) + weapons.Length) % weapons.Length;
            weapons [selected_weapon].gameObject.SetActive(true);
        }
    }
    public override State Update()
    {
        var state = _current.Recalculate() ? _current.Start() : _current.Update();

        if (state == State.FAILURE)
        {
            return(CalculateState(State.FAILURE));
        }
        else if (state == State.SUCCESS)
        {
            return(ToNextNode());
        }
        else
        {
            return(State.IN_PROGRESS);
        }
    }
Example #3
0
    IEnumerator Routine()
    {
        while (true)
        {
            if (currentNode == null)
            {
                DefineNode();
            }

            if (currentNode != null)
            {
                var state = currentNode.Recalculate() ? currentNode.Start() : currentNode.Update();

                if (state != BehaviourNode <X> .State.IN_PROGRESS)
                {
                    currentNode = null;
                }
            }

            yield return(null);
        }
    }
 public override State Update()
 {
     return(_currentNode.Recalculate() ? _currentNode.Start() : _currentNode.Update());
 }