예제 #1
0
 public void ProcessAction()
 {
     if (_currentAction != null && _currentAction.IsFinished == false)
     {
         Debug.Log($"Current action : {_currentAction.GetType()}");
         return;
     }
     if (_characterActions.Any() == false)
     {
         Debug.Log($"Current action : {_currentAction.GetType()}");
         return;
     }
     _currentAction = _characterActions.Dequeue();
     Debug.Log($"Current action : {_currentAction.GetType()}");
     _currentAction.Execute();
 }
예제 #2
0
    //TODO temp, rework when more character actions are implemented
    private void Update()
    {
        CharacterControl control = CharactersController.Singleton.activeCharacters[characterIndex];

        if (control != null)
        {
            //statusLabel.text = control.currentActions.Count.ToString();

            if (control.status == CharacterControl.Status.PerformingAction && control.currentActions.Count > 0)
            {
                CharacterAction currentAction = control.currentActions.Find(x => x.inProgress);

                if (currentAction != null && currentAction.GetType() == typeof(MineAction))
                {
                    statusLabel.text = "Mining";
                }
            }
            else if (!control.ReachedDestination)
            {
                statusLabel.text = "Moving";
            }
            else
            {
                statusLabel.text = "Idle";
            }

            fullInventoryNotification.gameObject.SetActive(control.character.inventory.IsFull);
        }
    }
예제 #3
0
 public void OnAbilityButtonPressed(string name)
 {
     if (allowedActions.ContainsKey(name))
     {
         currentAction = allowedActions[name];
         if (currentAction.GetType() == typeof(SpellAction))
         {
             fallbackAction = (SpellAction)currentAction;
         }
     }
     else
     {
         currentAction = allowedActions["Move"];
     }
 }
        private void DrawListElement(Rect elementRect, SerializedProperty element, bool isSelected)
        {
            if (element.objectReferenceValue != null)
            {
                Rect rect = elementRect;
                rect.y     += 2;
                rect.height = m_LineHeight;

                SerializedObject   elementObj = new SerializedObject(element.objectReferenceValue);
                SerializedProperty stateName  = elementObj.FindProperty("m_stateName");
                SerializedProperty isActive   = elementObj.FindProperty("m_isActive");
                SerializedProperty actionID   = elementObj.FindProperty("m_actionID");


                CharacterAction action = (CharacterAction)element.objectReferenceValue;
                //  Action name.
                rect.width = elementRect.width * 0.40f;
                if (action.IsActive)
                {
                    EditorGUI.LabelField(rect, string.Format("{0} ({1})", action.GetType().Name, "Active"), m_ActiveActionTextStyle);
                }
                else
                {
                    EditorGUI.LabelField(rect, action.GetType().Name, m_DefaultActionTextStyle);
                }


                //  Action state name.
                rect.x               += elementRect.width * 0.40f;
                rect.width            = elementRect.width * 0.36f;
                stateName.stringValue = EditorGUI.TextField(rect, stateName.stringValue);
                //  Action ID
                //rect.x = elementRect.width * 0.85f;
                rect.x            = elementRect.width - 36;
                rect.width        = 36;
                actionID.intValue = EditorGUI.IntField(rect, actionID.intValue);

                //  Toggle Enable
                rect.x         = elementRect.width + 12;
                rect.width     = 36;
                action.enabled = EditorGUI.Toggle(rect, action.enabled);
                //isActive.boolValue = EditorGUI.Toggle(rect, isActive.boolValue);
                //isActive.boolValue = action.enabled;

                elementObj.ApplyModifiedProperties();



                Event evt = Event.current;
                if (elementRect.Contains(evt.mousePosition))
                {
                    if (evt.button == 1 && evt.isMouse && evt.type == EventType.MouseUp)
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(new GUIContent("Add"), false, () => TestContextMenu(action.GetType().Name));
                        menu.AddItem(new GUIContent("Remove"), false, () => TestContextMenu(action.GetType().Name));
                        menu.ShowAsContext();
                        //ChangeStateName(stateName, action.GetType().Name);
                    }
                }
                //else {
                //    if (evt.button == 0 && evt.isMouse && evt.type == EventType.MouseUp)
                //    {
                //        if(action != null) action = null;
                //    }
                //}
            }
        }
예제 #5
0
 public void OnAbilityButtonPressed(string name)
 {
     if (allowedActions.ContainsKey(name))
     {
         currentAction = allowedActions[name];
         if (currentAction.GetType() == typeof(SpellAction))
         {
             fallbackAction = (SpellAction)currentAction;
         }
     }
     else
     {
         currentAction = allowedActions["Move"];
     }
 }