Esempio n. 1
0
 private void OnChange(CollectionManager.CollectionType type, Action.Type actionType, int count, int changeValue)
 {
     if (type == collectionType)
     {
         UpdateValue(count);
     }
 }
Esempio n. 2
0
 public void AddCurrentAction(Action.Type type)
 {
     actions.Add(new Action()
     {
         time = Time.time - Game.instance.loopStart, type = type, executed = false
     });
 }
Esempio n. 3
0
 public override bool SwitchActionCheck(Action.Type type)
 {
     SetTriggerNextAction(false);
     StopAction();
     Debug.Log("trigger normal action");
     return(true);
 }
Esempio n. 4
0
        public static void SetAction(ref Action action, Action.Type type)
        {
            Debug.Assert(pInstance != null);

            switch (type)
            {
            case Action.Type.Attack:
                action = pInstance.poActAttack;
                break;

            case Action.Type.SuperAttack:
                action = pInstance.poActSuperAttack;
                break;

            case Action.Type.Charge:
                action = pInstance.poActCharge;
                break;

            case Action.Type.Defend:
                action = pInstance.poActDefend;
                break;

            default:
                Debug.Assert(false);
                break;
            }
        }
Esempio n. 5
0
 public override bool SwitchActionCheck(Action.Type type)
 {
     isActionDone = true;
     SetTriggerNextAction(false);
     StopAction();
     return(true);
 }
Esempio n. 6
0
 public void ReceiveAction(Action.Type actionType, int playerId)
 {
     if (actionType == Action.Type.move || isGrowing)
     {
         return;
     }
     else if (actionType == Action.Type.plant)
     {
         if (stage == Stage.seed)
         {
             GrowthAction(playerId);
         }
     }
     else if (actionType == Action.Type.water)
     {
         if (stage == Stage.sapling)
         {
             GrowthAction(playerId);
         }
     }
     else if (actionType == Action.Type.pick)
     {
         if (stage == Stage.tree)
         {
             GrowthAction(playerId);
         }
     }
 }
Esempio n. 7
0
 private void OnChange(CollectionManager.CollectionType type, Action.Type actionType, int count, int changeValue)
 {
     if (type == CollectionManager.CollectionType.COIN && actionType == Action.Type.ADD)
     {
         IncreaseXP(changeValue);
     }
 }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        // Perform actions at random
        if (actions.Length > 0 && !IsPerformingAction())
        {
            Debug.Log("Performing action...");

            // Perform queued up action if there's one present
            Action action;
            if (nextAction != Action.Type.NONE)
            {
                action     = GetActionByType(nextAction);
                nextAction = Action.Type.NONE;
            }
            // or just select a random idle action
            else
            {
                action = SelectIdleAction();
            }

            // Check that we found an action with the specified type before executing
            if (action)
            {
                action.Execute();
            }
        }
    }
Esempio n. 9
0
 public void OnClickDefend()
 {
     if (lastInput != Action.Type.Defend)
     {
         this.pPunTurnManager.SendMove(Action.Type.Defend, false);
         lastInput = Action.Type.Defend;
     }
 }
Esempio n. 10
0
 public void OnClickCharge()
 {
     if (lastInput != Action.Type.Charge)
     {
         this.pPunTurnManager.SendMove(Action.Type.Charge, false);
         lastInput = Action.Type.Charge;
     }
 }
Esempio n. 11
0
 public void OnClickUltiAttack()
 {
     if (lastInput != Action.Type.SuperAttack)
     {
         this.pPunTurnManager.SendMove(Action.Type.SuperAttack, false);
         lastInput = Action.Type.SuperAttack;
     }
 }
Esempio n. 12
0
 public virtual bool SwitchActionCheck(Action.Type type)
 {
     isActionDone = true;
     SetTriggerNextAction(false);
     StopAction();
     Debug.Log("trigger normal action");
     return(true);
 }
Esempio n. 13
0
 public void RegisterChangedPrimitive(DataPrimitive primitive, Action.Type type, params object[] parameters)
 {
     ObservedChangedPrimitives.Enqueue(new Action
     {
         primitive  = primitive,
         type       = type,
         parameters = parameters
     });
 }
Esempio n. 14
0
    public void Unsubscribe(string source, Action.Type type, EventHandler <ActionArgs> function)
    {
        var key = new Action(machine.GetElementByName(source), type);

        if (actions.ContainsKey(key))
        {
            actions[key] -= function;
        }
    }
Esempio n. 15
0
 public override bool SwitchActionCheck(Action.Type type)
 {
     if (type == Action.Type.Attack) {
         //isActionDone = true;
         SetTriggerNextAction (false);
         StopAction ();
         return true;
     }
     return false;
 }
Esempio n. 16
0
 void DoActions(IEnumerable <int> nodes, Action.Type type)
 {
     foreach (var o in nodes)
     {
         var action = new Action(o, type);
         if (actions.TryGetValue(action, out EventHandler <ActionArgs> act))
         {
             act?.Invoke(this, new ActionArgs(o.ToString(), type));
         }
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Returns action with associated type, or null if none found
 /// </summary>
 protected Action GetActionByType(Action.Type type)
 {
     // If an action coroutine is in progress, return true
     foreach (Action action in actions)
     {
         if (action.type == type)
         {
             return(action);
         }
     }
     return(null);
 }
Esempio n. 18
0
    private void Update()
    {
        if (isPlayerVessel)
        {
            Action.Type actionMaybe = Action.fromInput;
            if (actionMaybe != Action.Type.none)
            {
                timeline.AddCurrentAction(actionMaybe);
            }
        }

        Action currentAction = timeline.currentAction;

        if (currentAction != null)
        {
            switch (currentAction.type)
            {
            case Action.Type.moveRight:
                transform.forward = Vector3.right;
                animator.SetBool(walkAnimBool, true);
                goingRight    = true;
                rightPrecedes = true;
                break;

            case Action.Type.stopRight:
                animator.SetBool(walkAnimBool, false);
                goingRight = false;
                break;

            case Action.Type.moveLeft:
                transform.forward = Vector3.left;
                animator.SetBool(walkAnimBool, true);
                goingLeft     = true;
                rightPrecedes = false;
                break;

            case Action.Type.stopLeft:
                animator.SetBool(walkAnimBool, false);
                goingLeft = false;
                break;

            case Action.Type.useObject:
                Lever.UseFromPosition(transform.position);
                break;
            }
            currentAction.executed = true;
        }


        rigidbody.velocity = new Vector3(velocityHorizontal, rigidbody.velocity.y, 0f);
    }
Esempio n. 19
0
    private void Change(ref int collection, Action.Type actionType, int changeValue)
    {
        switch (actionType)
        {
        case Action.Type.ADD:
            collection += changeValue;
            break;

        case Action.Type.SPEND:
            collection -= changeValue;
            break;

        case Action.Type.VALUE:
            collection = changeValue;
            break;
        }
    }
Esempio n. 20
0
    public bool SwitchAction(Action.Type type)
    {
        // can cancel action
        if (isActionDone || isCancelable)
        {
            isActionDone = true;
            return(true);
        }

        // can override action
        bool isNextAction = (triggerNextAction && nextAction != null && type == nextAction.GetType());

        if (isNextAction)
        {
            isActionDone = true;
            return(true);
        }
        else
        {
            return(SwitchActionCheck(type));
        }
    }
Esempio n. 21
0
    public void PlayAnimation(Action.Type actionType, Vector2 direction, bool isIdle = false)
    {
        string[] directionAnimations = idleDirectionAnimations;
        if (actionType == Action.Type.move)
        {
            actionBubble.SetActive(false);
            if (isIdle)
            {
                directionAnimations = idleDirectionAnimations;
            }
            else
            {
                directionAnimations = runDirectionAnimations;
            }
        }
        else if (actionType == Action.Type.plant)
        {
            directionAnimations = runDirectionAnimations;
            actionBubble.SetActive(true);
            actionIcon.sprite = Resources.Load <Sprite>(actionType.ToString());
        }
        else if (actionType == Action.Type.water)
        {
            directionAnimations = runDirectionAnimations;
            actionBubble.SetActive(true);
            actionIcon.sprite = Resources.Load <Sprite>(actionType.ToString());
        }
        else if (actionType == Action.Type.pick)
        {
            directionAnimations = runDirectionAnimations;
            actionBubble.SetActive(true);
            actionIcon.sprite = Resources.Load <Sprite>(actionType.ToString());
        }
        int directionIndex = DirectionToIndex(direction, 8);

        //tell the animator to play the requested state
        animator.Play(directionAnimations[directionIndex]);
    }
Esempio n. 22
0
 public Action GetActionByType(Action.Type actionType)
 {
     return(actionTable[actionType]);
 }
Esempio n. 23
0
 public void ChangeWalls(Action.Type actionType, int changeValue)
 {
     Change(ref walls, actionType, changeValue);
     OnChange(CollectionType.WALL, actionType, walls, changeValue);
 }
Esempio n. 24
0
 public void ChangeShakes(Action.Type actionType, int changeValue)
 {
     Change(ref shakes, actionType, changeValue);
     OnChange(CollectionType.SHAKE, actionType, shakes, changeValue);
 }
Esempio n. 25
0
 public void ChangePrizes(Action.Type actionType, int changeValue)
 {
     Change(ref prizes, actionType, changeValue);
     OnChange(CollectionType.PRIZE, actionType, prizes, changeValue);
 }
Esempio n. 26
0
 public void ChangeCoins(Action.Type actionType, int changeValue)
 {
     Change(ref coins, actionType, changeValue);
     OnChange(CollectionType.COIN, actionType, coins, changeValue);
 }
Esempio n. 27
0
 public void newAction(Action.Priority priority, Action.Type type)
 {
     _actionQueue.Add(new Action(priority, type));
 }
Esempio n. 28
0
        public override bool LoadProtoBuf(BehaviorPB.Node node)
        {
            if (!base.LoadProtoBuf(node))
                return false;

            if (node.action == null)
                return false;

            scriptPath = node.action.script_path;
            actionType = (Action.Type)Type;
            return true;
        }
Esempio n. 29
0
 public void SetAction(Action.Type type)
 {
     ActionManager.SetAction(ref this.pAction, type);
     Debug.Assert(this.pAction != null);
 }
Esempio n. 30
0
 public int IncreaseExperience(Action.Type action)
 {
     return(Experience += (int)action);
 }
Esempio n. 31
0
 public ActionArgs(string source, Action.Type type)
 {
     Source = source;
     Type   = type;
 }