示例#1
0
    public void RemoveViewer <T>(ActionViewer viewer) where T : GameAction
    {
        var typeName = ActionSystem.GetActionType <T>();

        if (actionViewerMap.ContainsKey(typeName))
        {
            actionViewerMap[typeName].Remove(viewer);
        }
    }
示例#2
0
    private void OnViewerComplete(ActionViewer viewer)
    {
        currentlyExecutingViewers.Remove(viewer);

        if (!IsExecutingAction())
        {
            CompleteAction();
        }
    }
示例#3
0
    public void AddViewer <T>(ActionViewer viewer) where T : GameAction
    {
        var typeName = ActionSystem.GetActionType <T>();

        if (!actionViewerMap.ContainsKey(typeName))
        {
            actionViewerMap.Add(typeName, new List <ActionViewer>(1));
        }

        actionViewerMap[typeName].Add(viewer);
    }
示例#4
0
    private void AddActionHandlingToGameObject(
        GameObject characterGameObject,
        Character characterData,
        bool isEnemy)
    {
        var isPlayer = !isEnemy;

        foreach (var action in characterData.Weapon.Actions)
        {
            ActionController actionController;
            ActionViewer     actionViewer = null;

            switch (action.ControllerType)
            {
            case ActionControllerType.GiantLazer:
                actionController = characterGameObject.AddComponent <GiantLazerActionController>();
                if (isPlayer)
                {
                    //TODO: create an action viewer for the giant laser so that maybe a player character can use it.
                    actionViewer = characterGameObject.AddComponent <ActionViewer>();
                }
                break;

            case ActionControllerType.Projectile:
                actionController = characterGameObject.AddComponent <ProjectileActionController>();
                if (isPlayer)
                {
                    actionViewer = characterGameObject.AddComponent <ActionViewer>();
                }
                break;

            case ActionControllerType.Default:
            default:
                actionController = characterGameObject.AddComponent <ActionController>();
                if (isPlayer)
                {
                    actionViewer = characterGameObject.AddComponent <ActionViewer>();
                }
                break;
            }

            actionController.ActionReference = action;
            if (isPlayer)
            {
                actionViewer.ActionReference = action;
            }
        }
    }
示例#5
0
        public override ActionBranch CollectActions(List <ActionViewer> scope, Dictionary <UInt32, ActionBranch> collected)
        {
            _ifActions   = null;
            _elseActions = null;
            List <ActionPortOut> ps = OutPortList;

            if (ps != null && ps.Count == 2)
            {
                if (ps[0].LinkedInPort != null)
                {
                    ActionViewer av = ps[0].LinkedInPort.Owner as ActionViewer;
                    if (av != null)
                    {
                        if (scope == null || scope.Contains(av))
                        {
                            ActionBranch a;
                            if (!collected.TryGetValue(av.ActionObject.FirstActionId, out a))
                            {
                                a = av.ActionObject.CollectActions(scope, collected);
                            }
                            _ifActions = a;
                        }
                    }
                }
                if (ps[1].LinkedInPort != null)
                {
                    ActionViewer av = ps[1].LinkedInPort.Owner as ActionViewer;
                    if (av != null)
                    {
                        if (scope == null || scope.Contains(av))
                        {
                            ActionBranch a;
                            if (!collected.TryGetValue(av.ActionObject.FirstActionId, out a))
                            {
                                a = av.ActionObject.CollectActions(scope, collected);
                            }
                            _elseActions = a;
                        }
                    }
                }
            }
            collected.Add(this.FirstActionId, this);
            return(this);
        }
 void Awake()
 {
     S = this;
 }