Пример #1
0
 public ResourcesUni getButton(Action action)
 {
     if(buttons.ContainsKey(action.getType ()))
         return buttons [action.getType ()];
     else
         return null;
 }
 public ResourcesUni getButton(Action action)
 {
     if (buttons.ContainsKey(action.getType()))
     {
         return(buttons[action.getType()]);
     }
     else
     {
         return(null);
     }
 }
Пример #3
0
 private void performAddAction(Action newAction)
 {
     getActionsList().Add(newAction);
     if (newAction.getType() == Action.CUSTOM || newAction.getType() == Action.CUSTOM_INTERACT)
     {
         getActions().Add(new CustomActionDataControl((CustomAction)newAction));
     }
     else
     {
         getActions().Add(new ActionDataControl(newAction));
     }
     controller.DataModified();
 }
Пример #4
0
        public void ActionSelected(Action action)
        {
            switch (action.getType())
            {
            case Action.DRAG_TO:
                OnBeginDrag(null);
                dragging = true;
                uAdventureInputModule.LookingForTarget = this.gameObject;
                break;

            default:
                if (Game.Instance.GameState.IsFirstPerson || !action.isNeedsGoTo())
                {
                    OnActionStarted(action);
                    Game.Instance.Execute(new EffectHolder(action.Effects), OnActionFinished);
                }
                else
                {
                    var       sceneMB = FindObjectOfType <SceneMB>();
                    Rectangle area    = GetInteractionArea(sceneMB);
                    PlayerMB.Instance.Do(action, area, OnActionStarted, OnActionFinished);
                }
                break;
            }
        }
Пример #5
0
    /**
     * Constructor that uses a default action
     *
     * @param action
     *            a normal action
     */

    public CustomAction(Action action)
        : base(
            action.getType(), action.getTargetId(), action.getConditions(), action.getEffects(), action.getNotEffects(),
            action.getClickEffects())
    {
        resources = new List <ResourcesUni>();
    }
Пример #6
0
        // Use this for initialization
        protected void Start()
        {
            spriteRenderer = GetComponent <SpriteRenderer>();

            if (this.action.getType() == Action.CUSTOM)
            {
                actionName = ((CustomAction)action).getName();

                CustomAction ca = action as CustomAction;
                foreach (ResourcesUni ru in ca.getResources())
                {
                    if (ConditionChecker.check(ru.getConditions()))
                    {
                        this.resource = ru;
                    }
                }
            }
            else
            {
                /*resource = new ResourcesUni ();
                 * CustomButton button = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.NORMAL_BUTTON);
                 * CustomButton highlighted = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.HIGHLIGHTED_BUTTON);
                 *
                 * if (button == null || highlighted == null) {
                 *  button = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.NORMAL_BUTTON);
                 *  highlighted = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.HIGHLIGHTED_BUTTON);
                 * }
                 *
                 * resource.addAsset (DescriptorData.NORMAL_BUTTON, button.getPath());
                 * resource.addAsset (DescriptorData.HIGHLIGHTED_BUTTON, highlighted.getPath());*/

                resource = GUIManager.Instance.Provider.getButton(this.action);

                actionName = ConstantNames.L["ES"].Actions[action.getType()];
            }

            Sprite tmp;

            if (this.action.getType() == Action.CUSTOM)
            {
                tmp = Game.Instance.ResourceManager.getSprite(resource.getAssetPath("buttonNormal"));
            }
            else
            {
                tmp = Game.Instance.ResourceManager.getSprite(resource.getAssetPath(DescriptorData.NORMAL_BUTTON));
            }

            spriteRenderer.sprite = tmp;
            if (InventoryManager.Instance.Opened)
            {
                this.gameObject.AddComponent <BoxCollider2D>();
            }
            else
            {
                this.gameObject.AddComponent <BoxCollider>();
            }
            //this.transform.localScale = new Vector3(tmp.width / 75f, tmp.height / 75f, 1);
        }
Пример #7
0
 public void execute(Action a, GameObject p)
 {
     this.action = a;
     if (a.getType() == "voler")
     {
         this.setDest(p.gameObject);
     }
     else
     {
         this.action.execute(p, robot.gameObject);
     }
 }
Пример #8
0
        public void ActionSelected(Action action)
        {
            InventoryManager.Instance.Opened = false;
            switch (action.getType())
            {
            case Action.GIVE_TO:
            case Action.USE_WITH:
            case Action.CUSTOM_INTERACT:
                // The texture that is already shown is either the icon or
                if (!cursor)
                {
                    cursor = new Texture2D(64, 64, TextureFormat.RGBA32, false, true);
                    try
                    {
                        var texture = sprite.texture;
                        ManuallyCopyTexture(texture, cursor);
                    }
                    catch
                    {
                        var texture = Transparent.CreateReadableTexture(sprite.texture);
                        ManuallyCopyTexture(texture, cursor);
                    }
                }

                Cursor.SetCursor(cursor, new Vector2(cursor.width, cursor.height) / 2f, CursorMode.ForceSoftware);
                GUIManager.Instance.LockCursor();
                uAdventureInputModule.LookingForTarget = this.gameObject;
                targetActionType = action.getType();
                break;

            default:
                OnActionStarted(action);
                Game.Instance.Execute(new EffectHolder(action.Effects), OnActionFinished);
                break;
            }
        }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        if (this.action.getType() == Action.CUSTOM)
        {
            name = ((CustomAction)action).getName();

            CustomAction ca = action as CustomAction;
            foreach (ResourcesUni ru in ca.getResources())
            {
                if (ConditionChecker.check(ru.getConditions()))
                {
                    this.resource = ru;
                }
            }
        }
        else
        {
            /*resource = new ResourcesUni ();
             * CustomButton button = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.NORMAL_BUTTON);
             * CustomButton highlighted = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.HIGHLIGHTED_BUTTON);
             *
             * if (button == null || highlighted == null) {
             *  button = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.NORMAL_BUTTON);
             *  highlighted = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.HIGHLIGHTED_BUTTON);
             * }
             *
             * resource.addAsset (DescriptorData.NORMAL_BUTTON, button.getPath());
             * resource.addAsset (DescriptorData.HIGHLIGHTED_BUTTON, highlighted.getPath());*/

            resource = GUIManager.Instance.Provider.getButton(this.action);

            name = ConstantNames.L ["ES"].Actions [action.getType()];
        }

        Texture2D tmp;

        if (this.action.getType() == Action.CUSTOM)
        {
            tmp = ResourceManager.Instance.getImage(resource.getAssetPath("buttonNormal"));
        }
        else
        {
            tmp = ResourceManager.Instance.getImage(resource.getAssetPath(DescriptorData.NORMAL_BUTTON));
        }

        this.GetComponent <Renderer> ().material.mainTexture = tmp;
        this.transform.localScale = new Vector3(tmp.width / 75f, tmp.height / 75f, 1);
    }
Пример #10
0
        /**
         * Returns the info of the actions contained in the list.
         *
         * @return Array with the information of the actions. It contains the type
         *         of the action, and information about whether they have conditions
         *         and effects
         */
        public string[][] getActionsInfo()
        {
            string[][] actionsInfo = null;

            // Create the list for the actions
            actionsInfo = new string[actionsList.Count][];
            for (int i = 0; i < actionsList.Count; i++)
            {
                actionsInfo[i] = new string[3];
            }

            // Fill the array with the info
            for (int i = 0; i < actionsList.Count; i++)
            {
                Action action = actionsList[i];

                if (action.getType() == Action.EXAMINE)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.ExamineAction");
                }
                else if (action.getType() == Action.GRAB)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.GrabAction");
                }
                else if (action.getType() == Action.CUSTOM)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.CustomAction", ((CustomAction)action).getName());
                }
                else if (action.getType() == Action.GIVE_TO)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.GiveToAction", action.getTargetId());
                }
                else if (action.getType() == Action.USE_WITH)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.UseWithAction", action.getTargetId());
                }
                else if (action.getType() == Action.CUSTOM_INTERACT)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.CustomInteractAction", action.getTargetId());
                }
                else if (action.getType() == Action.USE)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.UseAction");
                }
                else if (action.getType() == Action.TALK_TO)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.TalkToAction");
                }
                else if (action.getType() == Action.DRAG_TO)
                {
                    actionsInfo[i][0] = TC.get("ActionsList.DragToAction");
                }

                if (action.getConditions().IsEmpty())
                {
                    actionsInfo[i][1] = TC.get("GeneralText.No");
                }
                else
                {
                    actionsInfo[i][1] = TC.get("GeneralText.Yes");
                }

                if (action.getEffects().IsEmpty())
                {
                    actionsInfo[i][2] = TC.get("GeneralText.No");
                }
                else
                {
                    actionsInfo[i][2] = TC.get("GeneralText.Yes");
                }
            }

            return(actionsInfo);
        }
Пример #11
0
        public void ElementInteracted(bool finished, Interactuable interactuable, Action action)
        {
            var interactiveElement = interactuable as InteractiveElement;

            if (interactiveElement == null)
            {
                return;
            }

            if (!finished)
            {
                UpdateElementsInteracted(interactiveElement, action.getType().ToString(), interactiveElement.Element.getId());

                Game.Instance.GameState.BeginChangeAmbit();
            }
            else
            {
                string actionType = string.Empty;
                switch (action.getType())
                {
                case Action.CUSTOM: actionType = (action as CustomAction).getName(); break;

                case Action.CUSTOM_INTERACT: actionType = (action as CustomAction).getName(); break;

                case Action.DRAG_TO: actionType = "drag_to"; break;

                case Action.EXAMINE: actionType = "examine"; break;

                case Action.GIVE_TO: actionType = "give_to"; break;

                case Action.GRAB: actionType = "grab"; break;

                case Action.TALK_TO: actionType = "talk_to"; break;

                case Action.USE: actionType = "use"; break;

                case Action.USE_WITH: actionType = "use_with"; break;
                }

                if (!string.IsNullOrEmpty(action.getTargetId()))
                {
                    TrackerAsset.Instance.setVar("action_target", action.getTargetId());
                }

                if (!string.IsNullOrEmpty(actionType))
                {
                    TrackerAsset.Instance.setVar("action_type", actionType);
                }

                Game.Instance.GameState.EndChangeAmbitAsExtensions();
                var element = interactiveElement.Element;

                if (element is NPC)
                {
                    TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.Npc);
                }
                else if (element is Item)
                {
                    TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.Item);
                }
                else if (element is ActiveArea)
                {
                    TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.Item);
                }
                else
                {
                    TrackerAsset.Instance.GameObject.Interacted(element.getId(), GameObjectTracker.TrackedGameObject.GameObject);
                }
            }
        }
        public ActionDataControl(Action action)
        {
            this.action = action;

            this.resourcesList            = new List <ResourcesUni>();
            this.resourcesDataControlList = new List <ResourcesDataControl>();

            string actionName = null;

            // Store the type of the action
            switch (action.getType())
            {
            case Action.EXAMINE:
                actionType = Controller.ACTION_EXAMINE;
                actionName = "";
                break;

            case Action.GRAB:
                actionType = Controller.ACTION_GRAB;
                actionName = "";
                break;

            case Action.USE:
                actionType = Controller.ACTION_USE;
                actionName = "";
                break;

            case Action.CUSTOM:
                actionType = Controller.ACTION_CUSTOM;
                CustomAction custom = (CustomAction)action;
                actionName = custom.getName();
                break;

            case Action.USE_WITH:
                actionType = Controller.ACTION_USE_WITH;
                actionName = action.getTargetId();
                break;

            case Action.GIVE_TO:
                actionType = Controller.ACTION_GIVE_TO;
                actionName = action.getTargetId();
                break;

            case Action.CUSTOM_INTERACT:
                actionType = Controller.ACTION_CUSTOM_INTERACT;
                CustomAction custom2 = (CustomAction)action;
                actionName = custom2.getName() + " " + action.getTargetId();
                break;

            case Action.TALK_TO:
                actionType = Controller.ACTION_TALK_TO;
                actionName = action.getTargetId();
                break;

            case Action.DRAG_TO:
                actionType = Controller.ACTION_DRAG_TO;
                actionName = action.getTargetId();
                break;
            }

            // Create subcontrollers
            conditionsController = new ConditionsController(action.getConditions(), actionType, actionName);
            effectsController    = new EffectsController(action.getEffects());
            notEffectsController = new EffectsController(action.getNotEffects());
        }
        public string getTypeName()
        {
            string name = "";

            switch (action.getType())
            {
            case Action.EXAMINE:
                name = "Examine";
                break;

            case Action.GRAB:
                name = "Grab";
                break;

            case Action.USE:
                name = "Use";
                break;

            case Action.CUSTOM:
                name = "Custom";
                break;

            case Action.USE_WITH:
                name = "Use with";
                break;

            case Action.GIVE_TO:
                name = "Give to";
                break;

            case Action.CUSTOM_INTERACT:
                name = "Custom interact";
                break;

            case Action.TALK_TO:
                name = "Talk to";
                break;

            case Action.DRAG_TO:
                name = "Drag to";
                break;
            }
            return(name);
        }
Пример #14
0
        private void OnActionFinished(object interactuable)
        {
            Action action = interactuable as Action;

            if (interactuable is EffectHolder)
            {
                var effectHolder = interactuable as EffectHolder;
                if (executingAction.ContainsKey(effectHolder))
                {
                    action = executingAction[effectHolder];
                    executingAction.Remove(effectHolder);
                }
            }

            if (action == null)
            {
                return;
            }

            string actionType = string.Empty;

            switch (action.getType())
            {
            case Action.CUSTOM:          actionType = (action as CustomAction).getName();   break;

            case Action.CUSTOM_INTERACT: actionType = (action as CustomAction).getName();   break;

            case Action.DRAG_TO:         actionType = "drag_to";                            break;

            case Action.EXAMINE:         actionType = "examine";                            break;

            case Action.GIVE_TO:         actionType = "give_to";                            break;

            case Action.GRAB:            actionType = "grab";                               break;

            case Action.TALK_TO:         actionType = "talk_to";                            break;

            case Action.USE:             actionType = "use";                                break;

            case Action.USE_WITH:        actionType = "use_with";                           break;
            }

            if (!string.IsNullOrEmpty(action.getTargetId()))
            {
                TrackerAsset.Instance.setVar("action_target", action.getTargetId());
            }

            if (!string.IsNullOrEmpty(actionType))
            {
                TrackerAsset.Instance.setVar("action_type", actionType);
            }

            Game.Instance.GameState.EndChangeAmbitAsExtensions();

            if (Element is NPC)
            {
                TrackerAsset.Instance.GameObject.Interacted(Element.getId(), GameObjectTracker.TrackedGameObject.Npc);
            }
            else if (Element is Item)
            {
                TrackerAsset.Instance.GameObject.Interacted(Element.getId(), GameObjectTracker.TrackedGameObject.Item);
            }
            else if (Element is ActiveArea)
            {
                TrackerAsset.Instance.GameObject.Interacted(Element.getId(), GameObjectTracker.TrackedGameObject.Item);
            }
            else
            {
                TrackerAsset.Instance.GameObject.Interacted(Element.getId(), GameObjectTracker.TrackedGameObject.GameObject);
            }
        }
Пример #15
0
        private void OnActionStarted(object interactuable)
        {
            Action action = interactuable as Action;

            CompletablesController.Instance.ElementInteracted(this, action.getType().ToString(), action.getTargetId());
        }
Пример #16
0
 /**
  * Constructor that uses a default action
  *
  * @param action
  *            a normal action
  */
 public CustomAction(Action action)
     : base(action.getType(), action.getTargetId(), action.getConditions(), action.getEffects(), action.getNotEffects(),
         action.getClickEffects())
 {
     resources = new List<ResourcesUni>();
 }