Exemplo n.º 1
0
        public bool Update()
        {
            bool hasBeenUpdated = false;

            if (!Reached)
            {
                switch (Milestone.getType())
                {
                case Completable.Milestone.MilestoneType.COMPLETABLE:
                    var targetCompletable = AnalyticsExtension.Instance.GetCompletable(Milestone.getId());
                    Reached = targetCompletable.End.Reached;
                    break;

                case Completable.Milestone.MilestoneType.CONDITION:
                    Reached = ConditionChecker.check(Milestone.getConditions());
                    break;
                }

                if (Reached)
                {
                    hasBeenUpdated = true;
                }
            }

            return(hasBeenUpdated);
        }
Exemplo n.º 2
0
        public void OnQRCode(string content)
        {
            if (qr != null)
            {
                return;
            }

            bool blackList = QRPromptEffect.SelectionType == QRPromptEffect.ListType.BlackList;
            bool contained = QRPromptEffect.ValidIds.Contains(content);

            if ((blackList && !contained) || (!blackList && contained))
            {
                qr = Game.Instance.GameState.FindElement <QR>(content);
                if (qr != null && ConditionChecker.check(qr.Conditions))
                {// Si existe y además cumple las condiciones
                    // Mostramos el contenido y el resto de efectos
                    var effects = new Effects();
                    if (qr.Content != "")
                    {
                        effects.add(new SpeakPlayerEffect(qr.Content));
                    }
                    foreach (var effect in qr.Effects.getEffects())
                    {
                        effects.add(effect);
                    }

                    effectHolder = new EffectHolder(effects);
                    this.transform.GetChild(0).gameObject.SetActive(false);
                }
            }
        }
Exemplo n.º 3
0
    public void checkTimers()
    {
        foreach (Timer t in timers)
        {
            if (ConditionChecker.check(t.getInitCond()))
            {
                if (!isRunning(t))
                {
                    TimerState ts = new TimerState();
                    if (t.isCountDown())
                    {
                        ts.type         = TimerType.COUNTDOWN;
                        ts.max_time     = 0;
                        ts.current_time = System.Convert.ToInt64(t.getTime() * 1000) / 1000f;
                    }
                    else
                    {
                        ts.type         = TimerType.NORMAL;
                        ts.max_time     = System.Convert.ToInt64(t.getTime() * 1000) / 1000f;
                        ts.current_time = 0;
                    }
                    ts.timer = t;

                    running_timers.Add(ts);
                }
            }
            else if (isRunning(t))
            {
                removeFromRunning(t);
            }
        }
    }
Exemplo n.º 4
0
        public void UpdateConditions()
        {
            var display = !Element.IsRemoved() &&
                          (Reference.Conditions == null || ConditionChecker.check(Reference.Conditions));

            this.gameObject.SetActive(display);
        }
Exemplo n.º 5
0
        public void UpdateConditions()
        {
            var display = !Context.IsRemoved() &&
                          (Context.Conditions == null || ConditionChecker.check(Context.Conditions));

            this.gameObject.SetActive(display);
            this.Representable.checkResources();
        }
Exemplo n.º 6
0
 public void ReleaseElement(MapElement mapElement)
 {
     if (AdoptedElements.Contains(mapElement))
     {
         AdoptedElements.Remove(mapElement);
         if (mapElement.Conditions == null || ConditionChecker.check(mapElement.Conditions))
         {
             OrphanElements.Add(mapElement);
         }
     }
 }
Exemplo n.º 7
0
 protected void checkResources()
 {
     foreach (ResourcesUni resource in element.getResources())
     {
         if (ConditionChecker.check(resource.getConditions()))
         {
             this.resource = resource;
             break;
         }
     }
 }
Exemplo n.º 8
0
    public int checkGlobalState(string global_state)
    {
        int         ret = GlobalStateCondition.GS_SATISFIED;
        GlobalState gs  = data.getChapters() [current_chapter].getGlobalState(global_state);

        if (gs != null)
        {
            ret = ConditionChecker.check(gs);
        }
        return(ret);
    }
Exemplo n.º 9
0
 public void updateResource()
 {
     current_resource = null;
     foreach (ResourcesUni cr in player.getResources())
     {
         if (ConditionChecker.check(cr.getConditions()))
         {
             current_resource = cr;
             break;
         }
     }
 }
Exemplo n.º 10
0
    private void instanceElement <T>(ElementReference context) where T : Element
    {
        if (!ConditionChecker.check(context.getConditions()))
        {
            return;
        }

        if (!contexts.ContainsKey(context))
        {
            ElementReference new_context = new ElementReference(context.getTargetId(), context.getX(), context.getY());
            new_context.setScale(context.getScale());
            contexts.Add(context, new_context);
        }

        context = contexts [context];

        GameObject base_prefab;
        Transform  parent;
        Element    element;

        switch (typeof(T).ToString())
        {
        case "Atrezzo":
            base_prefab = Atrezzo_Prefab;
            parent      = Atrezzos;
            element     = Game.Instance.GameState.getAtrezzo(context.getTargetId());
            break;

        case "NPC":
            base_prefab = Character_Prefab;
            parent      = Characters;
            element     = Game.Instance.GameState.getCharacter(context.getTargetId());
            break;

        case "Item":
            base_prefab = Object_Prefab;
            parent      = Objects;
            element     = Game.Instance.GameState.getObject(context.getTargetId());
            break;

        default:
            return;
        }

        GameObject ret   = GameObject.Instantiate(base_prefab);
        Transform  trans = ret.GetComponent <Transform> ();

        ret.GetComponent <Representable> ().Context = context;
        ret.GetComponent <Representable> ().Element = element;
        trans.SetParent(parent);
    }
Exemplo n.º 11
0
    public bool execute()
    {
        bool             forcewait = false;
        ConversationLine l;

        if (node != null)
        {
            switch (node.getType())
            {
            case ConversationNodeViewEnum.DIALOGUE:
                while (current_line < node.getLineCount() && !forcewait)
                {
                    l = node.getLine(current_line);
                    if (ConditionChecker.check(l.getConditions()))
                    {
                        forcewait = true;
                        Game.Instance.talk(l.getText(), l.getName());
                    }
                    current_line++;
                }
                if (!forcewait && additional_effects != null && additional_effects.effects.Count > 0)
                {
                    forcewait = additional_effects.execute();
                }

                break;

            case ConversationNodeViewEnum.OPTION:
                if (this.child == -2)
                {
                    Game.Instance.showOptions(this);
                    forcewait = true;
                }
                else
                {
                    if (additional_effects != null)
                    {
                        forcewait = additional_effects.execute();
                    }
                    else
                    {
                        forcewait = false;
                    }
                }
                break;
            }
        }

        return(forcewait);
    }
Exemplo n.º 12
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);
    }
Exemplo n.º 13
0
            public bool Update()
            {
                if (!reached)
                {
                    if (type == MilestoneType.CONDITION)
                    {
                        reached = ConditionChecker.check(conditions);
                    }
                    else if (type == MilestoneType.COMPLETABLE)
                    {
                        reached = CompletableController.Instance.getCompletable(id).getEnd().reached;
                    }
                }

                return(reached);
            }
Exemplo n.º 14
0
    public InteractuableResult Interacted(RaycastHit hit = default(RaycastHit))
    {
        InteractuableResult res = InteractuableResult.IGNORES;

        if (interactable)
        {
            List <Action> available = new List <Action> ();

            foreach (Action a in charData.getActions())
            {
                if (ConditionChecker.check(a.getConditions()))
                {
                    bool addaction = true;
                    foreach (Action a2 in available)
                    {
                        if ((a.getType() == Action.CUSTOM || a.getType() == Action.CUSTOM_INTERACT) && (a2.getType() == Action.CUSTOM || a2.getType() == Action.CUSTOM_INTERACT))
                        {
                            if (((CustomAction)a).getName() == ((CustomAction)a2).getName())
                            {
                                addaction = false;
                                break;
                            }
                        }
                        else if (a.getType() == a2.getType())
                        {
                            addaction = false;
                            break;
                        }
                    }

                    if (addaction)
                    {
                        available.Add(a);
                    }
                }
            }

            if (available.Count > 0)
            {
                Game.Instance.showActions(available, Input.mousePosition);
                res = InteractuableResult.DOES_SOMETHING;
            }
        }

        return(res);
    }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        foreach (ResourcesUni ar in ad.getResources())
        {
            if (ConditionChecker.check(ar.getConditions()))
            {
                Texture2DHolder th  = new Texture2DHolder(ar.getAssetPath(Atrezzo.RESOURCE_TYPE_IMAGE));
                Texture2D       tmp = th.Texture;
                this.GetComponent <Renderer> ().material.mainTexture = tmp;
                this.transform.localScale = new Vector3(tmp.width / 10, tmp.height / 10, 1) * context.getScale();

                Vector2 tmppos = new Vector2(context.getX(), context.getY()) / 10 + (new Vector2(0, -transform.localScale.y)) / 2;
                transform.localPosition = new Vector3(tmppos.x, 60 - tmppos.y, -context.getLayer());
                break;
            }
        }
    }
Exemplo n.º 16
0
    public void exit()
    {
        //Game.Instance.hideMenu ();
        if (ConditionChecker.check(ed.getConditions()))
        {
            Game.Instance.Execute(new EffectHolder(ed.getEffects()));
            GUIManager.Instance.setCursor("default");
            Game.Instance.renderScene(ed.getNextSceneId(), ed.getTransitionTime(), ed.getTransitionType());

            if (ed.getPostEffects() != null)
            {
                Game.Instance.Execute(new EffectHolder(ed.getPostEffects()));
            }
        }
        else if (ed.isHasNotEffects())
        {
            Game.Instance.Execute(new EffectHolder(ed.getNotEffects()));
        }
    }
Exemplo n.º 17
0
    void OnGUI()
    {
        float guiscale = Screen.width / 800f;

        style.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
        style.button.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
        optionlabel.fontSize  = Mathf.RoundToInt(guiscale * 36);
        style.GetStyle("talk_player").fontSize = Mathf.RoundToInt(guiscale * 20);

        float rectwith = guiscale * 330;

        switch (guistate)
        {
        case guiState.ANSWERS_MENU:
            GUILayout.BeginArea(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f));
            GUILayout.BeginVertical();
            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

            GUILayout.Label(GUIManager.Instance.Last, optionlabel);
            for (int i = 0; i < options.getLineCount(); i++)
            {
                ConversationLine ono = options.getLine(i);
                if (ConditionChecker.check(options.getLineConditions(i)))
                {
                    if (GUILayout.Button((string)ono.getText(), style.button))
                    {
                        GameObject.Destroy(blur);
                        guioptions.clicked(i);
                        Tracker.T().Choice(GUIManager.Instance.Last, ono.getText());
                        Tracker.T().RequestFlush();
                        Interacted();
                    }
                }
                ;
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
            break;

        default: break;
        }
    }
Exemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        foreach (ResourcesUni cr in cd.getResources())
        {
            if (ConditionChecker.check(cr.getConditions()))
            {
                string path = cr.getAssetPath(NPC.RESOURCE_TYPE_STAND_UP);

                //current_anim = Loader.loadAnimation(AssetsController.InputStreamCreatorEditor.getInputStreamCreator (path),path,new EditorImageLoader());
                current_anim = ResourceManager.Instance.getAnimation(path);

                break;
            }
        }

        this.gameObject.name = cd.getId();

        current_frame = 0;

        // ## ANIMATION METHOD ##

        /*Texture2D tmp = current_anim.getFrame(0).getImage(false,false,0).texture;
         * update_ratio = current_anim.getFrame(0).getTime();//Duration/1000f;*/

        // ## EANIM METHOD ##
        Texture2D tmp = current_anim.frames[0].Image;

        update_ratio = current_anim.frames[0].Duration / 1000f;


        this.GetComponent <Renderer> ().material.mainTexture = tmp;
        this.transform.localScale = new Vector3(tmp.width / 10, tmp.height / 10, 1) * context.getScale();

        Vector2 tmppos = new Vector2(context.getX(), context.getY()) / 10 + (new Vector2(0, -transform.localScale.y)) / 2;

        transform.localPosition = new Vector3(tmppos.x, 60 - tmppos.y, -context.getLayer());
    }
Exemplo n.º 19
0
    void Start()
    {
        foreach (ResourcesUni cr in od.getResources())
        {
            if (ConditionChecker.check(cr.getConditions()))
            {
                current_resource = cr;
                string    path = cr.getAssetPath(Item.RESOURCE_TYPE_IMAGE);
                Texture2D th   = ResourceManager.Instance.getImage(path);

                this.GetComponent <Renderer> ().material.mainTexture = th;
                this.transform.localScale = new Vector3(th.width / 10, th.height / 10, 1) * context.getScale();
                break;
            }
        }

        this.gameObject.name = od.getId();

        Vector2 tmppos = new Vector2(context.getX(), context.getY()) / 10 + (new Vector2(0, -transform.localScale.y)) / 2;

        transform.localPosition = new Vector3(tmppos.x, 60 - tmppos.y, -context.getLayer());

        hasOverSprite = current_resource.getAssetPath(Item.RESOURCE_TYPE_IMAGEOVER) != null;
    }
Exemplo n.º 20
0
    void OnGUI()
    {
        float guiscale = Screen.width / 800f;

        style.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
        style.button.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
        optionlabel.fontSize  = Mathf.RoundToInt(guiscale * 36);
        //style.label.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.GetStyle("talk_player").fontSize = Mathf.RoundToInt(guiscale * 20);

        float rectwith = guiscale * 330;

        switch (guistate)
        {
        case guiState.TALK_PLAYER:
            /*GUILayout.BeginArea (new Rect ((Screen.width/2)-rectwith/2, 50, rectwith, 400));
             * GUILayout.BeginHorizontal ();
             * GUILayout.Box (guitext,style.GetStyle("talk_player"));
             * GUILayout.EndHorizontal ();
             * GUILayout.EndArea ();*/
            break;

        case guiState.TALK_CHARACTER:
            /*GUIStyle current = new GUIStyle(style.box);
             * if (this.guitalkerObject != null) {
             * position = Camera.current.WorldToScreenPoint (this.guitalkerObject.transform.position);
             * Color tmp = Color.black;
             * NPC cha = data.getChapters () [current_chapter].getCharacter (guitalker);
             *
             *
             * ColorUtility.TryParseHtmlString(
             *  cha.getTextFrontColor()
             *  ,out tmp);
             *
             * current.normal.textColor = tmp;
             * current.normal.background = BorderGenerator.generateFor (cha);
             * }else
             * position = new Vector2(Screen.width/2,100);
             *
             * if(position.x <= rectwith/2)
             * position.x = rectwith/2;
             * else if(position.x >= (Screen.width - rectwith/2) )
             * position.x = (Screen.width - rectwith/2);
             *
             * GUILayout.BeginArea (
             * new Rect (position.x-rectwith/2,
             *  Screen.height
             *  - position.y
             *  - (this.guitalkerObject.GetComponent<CharacterMB>().getHeight())*guiscale/2
             *  - current.CalcHeight(new GUIContent(guitext),rectwith), rectwith, 400)
             * );
             * GUILayout.BeginHorizontal ();
             * GUILayout.Box (guitext,current);
             * GUILayout.EndHorizontal ();
             * GUILayout.EndArea ();*/
            break;

        case guiState.ANSWERS_MENU:
            GUILayout.BeginArea(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f));
            GUILayout.BeginVertical();
            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

            GUILayout.Label(guitext, optionlabel);
            for (int i = 0; i < options.getLineCount(); i++)
            {
                ConversationLine ono = options.getLine(i);
                if (ConditionChecker.check(options.getLineConditions(i)))
                {
                    if (GUILayout.Button((string)ono.getText(), style.button))
                    {
                        GameObject.Destroy(blur);
                        guioptions.clicked(i);
                        Interacted();
                    }
                }
                ;
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
            break;

        case guiState.LOADING_GAME:
            break;

        case guiState.NOTHING:
            /*if(loader_state == loaderState.LOADING){
             *  GUILayout.BeginArea (new Rect (Screen.width*0.1f, Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f));
             *  GUILayout.BeginVertical ();
             *  GUILayout.Label ("Cargando",style.label);
             *
             *  if(totals != null){
             *      GUILayout.Box ("Personajes: " + this.characters.Count + " de " + totals["Characters"],style.box);
             *      GUILayout.Box ("Objetos: " + this.objects.Count + " de " + totals["Objects"],style.box);
             *      GUILayout.Box ("Objetos de Atrezzo: " + this.atrezzos.Count + " de " + totals["Atrezzos"],style.box);
             *      GUILayout.Box ("Estados Globales: " + this.global_states.Count + " de " + totals["Global-States"],style.box);
             *      GUILayout.Box ("Grafos de Conversacion: " + this.graph_conversations.Count + " de " + totals["Graph-conversations"],style.box);
             *      GUILayout.Box ("Macros: " + this.macros.Count + " de " + totals["Macros"],style.box);
             *
             *      GUILayout.Box ("Escenas: " + this.scenes.Count + " de " + totals["Scene"],style.box);
             *  }
             *
             *
             *  GUILayout.EndVertical ();
             *  GUILayout.EndArea ();
             * }*/
            break;

        case guiState.GAME_SELECTION:
        /*GUILayout.BeginArea (new Rect (Screen.width*0.1f, Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f));
         * GUILayout.BeginVertical ();
         * string[] games = Directory.GetDirectories("Games/");
         *
         * GUILayout.Label("eAdventure Loader v0.1",style.label);
         * foreach(string game in games){
         *  if(GUILayout.Button (game.Split('/')[1],style.button)){
         *      this.selected_game = game + "/";
         *      //this.startLoad();
         *  };
         * }
         * GUILayout.EndVertical ();
         * GUILayout.EndArea ();
         * break;*/
        default: break;
        }
    }
Exemplo n.º 21
0
 protected virtual bool Check()
 {
     return(!Game.Instance.isSomethingRunning() && ConditionChecker.check(Action.Conditions) && CustomChecks());
 }
Exemplo n.º 22
0
    //private SlidesceneResource current_resource;

    public void renderScene()
    {
        ElementReference auxEleRef;

        switch (sd.getType())
        {
        case GeneralScene.GeneralSceneSceneType.VIDEOSCENE:
            StartCoroutine(loadMovie());
            this.transform.FindChild("Background").localPosition = new Vector3(40, 30, 20);
            break;

        case GeneralScene.GeneralSceneSceneType.SCENE:
            Scene rsd = (Scene)sd;
            foreach (ResourcesUni sr in rsd.getResources())
            {
                if (ConditionChecker.check(sr.getConditions()))
                {
                    Texture2DHolder th  = new Texture2DHolder(sr.getAssetPath(Scene.RESOURCE_TYPE_BACKGROUND));
                    Texture2D       tmp = th.Texture;

                    Transform background = this.transform.FindChild("Background");
                    background.GetComponent <Renderer> ().material.mainTexture = tmp;
                    float scale = (tmp.width / (tmp.height / 600f)) / 800f;

                    this.transform.position         = new Vector3(40, 30, 20);
                    background.localPosition        = new Vector3(((80 * scale) - 80) / 2f, 0, 20);
                    background.transform.localScale = new Vector3(scale * 80, 60, 1);
                    break;
                }
            }

            Transform characters = this.transform.FindChild("Characters");
            foreach (Transform child in characters)
            {
                GameObject.Destroy(child.gameObject);
            }

            foreach (ElementReference cr in rsd.getCharacterReferences())
            {
                if (ConditionChecker.check(cr.getConditions()))
                {
                    GameObject ret   = GameObject.Instantiate(Character_Prefab);
                    Transform  trans = ret.GetComponent <Transform> ();
                    ret.GetComponent <CharacterMB> ().context  = cr;
                    ret.GetComponent <CharacterMB> ().charData = Game.Instance.getCharacter(cr.getTargetId());
                    trans.SetParent(characters);
                }
            }

            Transform objects = this.transform.FindChild("Objects");
            foreach (Transform child in objects)
            {
                GameObject.Destroy(child.gameObject);
            }

            List <ElementReference> items = rsd.getItemReferences();

            ElementReference tmpElement;
            foreach (ElementReference ir in rsd.getItemReferences())
            {
                if (ConditionChecker.check(ir.getConditions()))
                {
                    if (!contexts.ContainsKey(ir))
                    {
                        tmpElement = new ElementReference(ir.getTargetId(), ir.getX(), ir.getY());
                        tmpElement.setScale(ir.getScale());
                        contexts.Add(ir, tmpElement);
                    }

                    GameObject ret   = GameObject.Instantiate(Object_Prefab);
                    Transform  trans = ret.GetComponent <Transform> ();
                    ret.GetComponent <ObjectMB> ().context = contexts[ir];
                    ret.GetComponent <ObjectMB> ().objData = Game.Instance.getObject(ir.getTargetId());
                    trans.SetParent(objects);
                }
            }

            Transform atrezzos = this.transform.FindChild("Atrezzos");
            foreach (Transform child in atrezzos)
            {
                GameObject.Destroy(child.gameObject);
            }

            foreach (ElementReference ir in rsd.getAtrezzoReferences())
            {
                if (ConditionChecker.check(ir.getConditions()))
                {
                    GameObject ret   = GameObject.Instantiate(Atrezzo_Prefab);
                    Transform  trans = ret.GetComponent <Transform> ();
                    ret.GetComponent <AtrezzoMB> ().context = ir;
                    ret.GetComponent <AtrezzoMB> ().atrData = Game.Instance.getAtrezzo(ir.getTargetId());
                    trans.SetParent(atrezzos);
                }
            }

            Transform activeareas = this.transform.FindChild("ActiveAreas");
            foreach (Transform child in activeareas)
            {
                GameObject.Destroy(child.gameObject);
            }

            foreach (ActiveArea ad in rsd.getActiveAreas())
            {
                if (ConditionChecker.check(ad.getConditions()))
                {
                    GameObject ret   = GameObject.Instantiate(ActiveArea_Prefab);
                    Transform  trans = ret.GetComponent <Transform> ();
                    ret.GetComponent <ActiveAreaMB> ().aaData = ad;
                    trans.localScale = new Vector3(ad.getWidth() / 10f, ad.getHeight() / 10f, 1);
                    Vector2 tmppos = new Vector2(ad.getX(), ad.getY()) / 10 + (new Vector2(trans.localScale.x, trans.localScale.y)) / 2;

                    trans.localPosition = new Vector2(tmppos.x, 60 - tmppos.y);
                    trans.SetParent(activeareas);
                }
            }

            Transform exits = this.transform.FindChild("Exits");
            foreach (Transform child in exits)
            {
                GameObject.Destroy(child.gameObject);
            }

            foreach (Exit ed in rsd.getExits())
            {
                if (ed.isHasNotEffects() || ConditionChecker.check(ed.getConditions()))
                {
                    GameObject ret   = GameObject.Instantiate(Exit_Prefab);
                    Transform  trans = ret.GetComponent <Transform> ();
                    ret.GetComponent <ExitMB> ().exitData = ed;
                    trans.localScale = new Vector3(ed.getWidth() / 10f, ed.getHeight() / 10f, 1);
                    Vector2 tmppos = new Vector2(ed.getX(), ed.getY()) / 10 + (new Vector2(trans.localScale.x, trans.localScale.y)) / 2;

                    trans.localPosition = new Vector2(tmppos.x, 60 - tmppos.y);
                    trans.SetParent(exits);
                }
            }

            if (!Game.Instance.isFirstPerson())
            {
                lines = new List <LineHandler> ();
                foreach (Trajectory.Side side in rsd.getTrajectory().getSides())
                {
                    lines.Add(new LineHandler(rsd.getTrajectory().getNodeForId(side.getIDStart())
                                              , rsd.getTrajectory().getNodeForId(side.getIDEnd())
                                              , side));
                }
                updateNeighbours();

                if (player_context == null)
                {
                    //Vector2 pos = LineHandler.nodeToVector2 (lines [lines.Count-1].end);
                    Trajectory.Node pos = lines [lines.Count - 1].end;
                    player_context = new ElementReference("Player", pos.getX(), pos.getY(), rsd.getPlayerLayer());
                    player_context.setScale(pos.getScale());
                }
                /*GameObject.Destroy(this.transform.FindChild ("Player"));*/

                player = GameObject.Instantiate(Player_Prefab).GetComponent <PlayerMB>();
                player.transform.parent = characters;
                player.playerData       = Game.Instance.getPlayer();
                player.context          = player_context;
            }

            break;

        case GeneralScene.GeneralSceneSceneType.SLIDESCENE:
            Slidescene ssd = (Slidescene)sd;
            foreach (ResourcesUni r in ssd.getResources())
            {
                if (ConditionChecker.check(r.getConditions()))
                {
                    this.slides = new eAnim(r.getAssetPath(Slidescene.RESOURCE_TYPE_SLIDES));
                    this.transform.FindChild("Background").GetComponent <Renderer> ().material.mainTexture = this.slides.frames[0].Image;
                    this.transform.position = new Vector3(40, 30, 20);
                    break;
                }
            }
            break;
        }
    }
Exemplo n.º 23
0
    //private SlidesceneResource current_resource;

    public void renderScene()
    {
        ElementReference auxEleRef;

        switch (sd.getType())
        {
        case GeneralScene.GeneralSceneSceneType.VIDEOSCENE:
            movie = ResourceManager.Instance.getVideo(((Videoscene)sd).getResources() [0].getAssetPath(Videoscene.RESOURCE_TYPE_VIDEO));
            Debug.Log("back into scene");
            setMovie();
            playMovie();
            this.transform.FindChild("Background").localPosition = new Vector3(40, 30, 20);
            interactuable = true;
            break;

        case GeneralScene.GeneralSceneSceneType.SCENE:

            loadParents();

            Scene rsd = (Scene)sd;
            foreach (ResourcesUni sr in rsd.getResources())
            {
                if (ConditionChecker.check(sr.getConditions()))
                {
                    Texture2D tmp = ResourceManager.Instance.getImage(sr.getAssetPath(Scene.RESOURCE_TYPE_BACKGROUND));

                    Transform background = this.transform.FindChild("Background");
                    background.GetComponent <Renderer> ().material.mainTexture = tmp;
                    float scale = (tmp.width / (tmp.height / 600f)) / 800f;

                    this.transform.position         = new Vector3(40, 30, 20);
                    background.localPosition        = new Vector3(((80 * scale) - 80) / 2f, 0, 20);
                    background.transform.localScale = new Vector3(scale * 80, 60, 1);
                    break;
                }
            }

            //###################### CHARACTERS ######################
            deleteChilds(Characters);
            foreach (ElementReference context in rsd.getCharacterReferences())
            {
                instanceElement <NPC> (context);
            }

            //###################### OBJECTS ######################
            deleteChilds(Objects);
            foreach (ElementReference context in rsd.getItemReferences())
            {
                instanceElement <Item> (context);
            }

            //###################### ATREZZOS ######################
            deleteChilds(Atrezzos);
            foreach (ElementReference context in rsd.getAtrezzoReferences())
            {
                instanceElement <Atrezzo> (context);
            }

            //###################### ACTIVEAREAS ######################
            deleteChilds(ActiveAreas);

            foreach (ActiveArea ad in rsd.getActiveAreas())
            {
                if (ConditionChecker.check(ad.getConditions()))
                {
                    instanceRectangle <ActiveArea> (ad);
                }
            }

            //###################### EXITS ######################
            deleteChilds(Exits);

            foreach (Exit exit in rsd.getExits())
            {
                if (exit.isHasNotEffects() || ConditionChecker.check(exit.getConditions()))
                {
                    instanceRectangle <Exit> (exit);
                }
            }


            if (!Game.Instance.GameState.isFirstPerson())
            {
                trajectory = new TrajectoryHandler(rsd.getTrajectory());
                if (player_context == null)
                {
                    //Vector2 pos = LineHandler.nodeToVector2 (lines [lines.Count-1].end);
                    Trajectory.Node pos = trajectory.getLastNode();
                    player_context = new ElementReference("Player", pos.getX(), pos.getY(), rsd.getPlayerLayer());
                    player_context.setScale(pos.getScale());
                }
                /*GameObject.Destroy(this.transform.FindChild ("Player"));*/

                player = GameObject.Instantiate(Player_Prefab).GetComponent <PlayerMB>();
                player.transform.parent = Characters;
                player.Element          = Game.Instance.GameState.getPlayer();
                player.Context          = player_context;
            }

            break;

        case GeneralScene.GeneralSceneSceneType.SLIDESCENE:
            Slidescene ssd = (Slidescene)sd;
            foreach (ResourcesUni r in ssd.getResources())
            {
                if (ConditionChecker.check(r.getConditions()))
                {
                    this.slides = ResourceManager.Instance.getAnimation(r.getAssetPath(Slidescene.RESOURCE_TYPE_SLIDES));
                    this.transform.FindChild("Background").GetComponent <Renderer> ().material.mainTexture = this.slides.frames[0].Image;
                    this.transform.position = new Vector3(40, 30, 20);
                    break;
                }
            }
            break;
        }
    }
Exemplo n.º 24
0
    public InteractuableResult Interacted(RaycastHit hit = new RaycastHit())
    {
        InteractuableResult ret = InteractuableResult.IGNORES;

        if (aad.getInfluenceArea() != null)
        {
        }

        switch (aad.getBehaviour())
        {
        case Item.BehaviourType.FIRST_ACTION:
            foreach (Action a in aad.getActions())
            {
                if (ConditionChecker.check(a.getConditions()))
                {
                    Game.Instance.Execute(new EffectHolder(a.getEffects()));
                    break;
                }
            }
            ret = InteractuableResult.DOES_SOMETHING;
            break;

        case Item.BehaviourType.NORMAL:
            List <Action> available = new List <Action> ();
            foreach (Action a in aad.getActions())
            {
                if (ConditionChecker.check(a.getConditions()))
                {
                    bool addaction = true;
                    foreach (Action a2 in available)
                    {
                        if ((a.getType() == Action.CUSTOM || a.getType() == Action.CUSTOM_INTERACT) && (a2.getType() == Action.CUSTOM || a2.getType() == Action.CUSTOM_INTERACT))
                        {
                            if (((CustomAction)a).getName() == ((CustomAction)a2).getName())
                            {
                                addaction = false;
                                break;
                            }
                        }
                        else if (a.getType() == a2.getType())
                        {
                            addaction = false;
                            break;
                        }
                    }

                    if (addaction)
                    {
                        available.Add(a);
                    }
                }
            }

            //We check if it's an examine action, otherwise we create one and add it
            bool   addexamine = true;
            string desc       = aad.getDescription(0).getDetailedDescription();
            if (desc != "")
            {
                foreach (Action a in available)
                {
                    if (a.getType() == Action.EXAMINE)
                    {
                        addexamine = false;
                        break;
                    }
                }

                if (addexamine)
                {
                    Action  ex    = new Action(Action.EXAMINE);
                    Effects exeff = new Effects();
                    exeff.add(new SpeakPlayerEffect(desc));
                    ex.setEffects(exeff);
                    available.Add(ex);
                }
            }

            if (available.Count > 0)
            {
                Game.Instance.showActions(available, Input.mousePosition);
                ret = InteractuableResult.DOES_SOMETHING;
            }
            break;

        case Item.BehaviourType.ATREZZO:
        default:
            ret = InteractuableResult.IGNORES;
            break;
        }

        return(ret);
    }
Exemplo n.º 25
0
    public bool execute()
    {
        bool forcewait = false;

        if (!(runs_once && times_runed > 0))
        {
            if (effect == null || effect.getConditions() == null)
            {
                Debug.Log("Asd");
            }
            else
            {
                if (!validated)
                {
                    is_valid  = ConditionChecker.check(effect.getConditions());
                    validated = true;
                }

                if (is_valid)
                {
                    switch (effect.getType())
                    {
                    case EffectType.ACTIVATE:
                        Game.Instance.GameState.setFlag(((ActivateEffect)effect).getTargetId(), FlagCondition.FLAG_ACTIVE);
                        break;

                    case EffectType.DEACTIVATE:
                        Game.Instance.GameState.setFlag(((DeactivateEffect)effect).getTargetId(), FlagCondition.FLAG_INACTIVE);
                        break;

                    case EffectType.SPEAK_PLAYER:
                        Game.Instance.talk(((SpeakPlayerEffect)effect).getLine(), null);
                        forcewait = true;
                        break;

                    case EffectType.SPEAK_CHAR:
                        Game.Instance.talk(((SpeakCharEffect)effect).getLine(), ((SpeakCharEffect)effect).getTargetId());
                        forcewait = true;
                        break;

                    case EffectType.TRIGGER_SCENE:
                        runs_once = false;
                        Game.Instance.renderScene(((TriggerSceneEffect)effect).getTargetId());
                        break;

                    case EffectType.TRIGGER_CUTSCENE:
                        runs_once = false;
                        TriggerCutsceneEffect tce = (TriggerCutsceneEffect)effect;
                        if (times_runed > 0)
                        {
                            forcewait = ((SceneMB)aditional_info ["scene"]).Interacted() == InteractuableResult.REQUIRES_MORE_INTERACTION;
                        }
                        else
                        {
                            aditional_info = new Dictionary <string, object> ();
                            aditional_info.Add("lastscene", Game.Instance.GameState.CurrentScene);
                            aditional_info.Add("scene", Game.Instance.renderScene(tce.getTargetId()).GetComponent <SceneMB> ());
                            forcewait = true;
                        }

                        if (!forcewait && ((Slidescene)((SceneMB)aditional_info ["scene"]).sceneData).getNext() == Slidescene.GOBACK)
                        {
                            string last = (string)aditional_info ["lastscene"];
                            Game.Instance.renderScene(last);
                        }

                        break;

                    case EffectType.TRIGGER_LAST_SCENE:
                        runs_once = false;
                        Game.Instance.renderLastScene();
                        break;

                    case EffectType.TRIGGER_CONVERSATION:
                        runs_once = false;
                        runs_once = false;
                        if (times_runed == 0)
                        {
                            TriggerConversationEffect tcoe = (TriggerConversationEffect)effect;
                            this.aditional_info.Add("conversation", new GraphConversationHolder(Game.Instance.GameState.getConversation(tcoe.getTargetId())));
                        }
                        forcewait = ((GraphConversationHolder)this.aditional_info ["conversation"]).execute();
                        break;

                    case EffectType.RANDOM_EFFECT:
                        runs_once = false;
                        RandomEffect re = (RandomEffect)effect;

                        if (!aditional_info.ContainsKey("first"))
                        {
                            aditional_info.Add("first", new EffectHolderNode(re.getPositiveEffect()));
                            aditional_info.Add("second", new EffectHolderNode(re.getNegativeEffect()));
                        }

                        if (times_runed == 0)
                        {
                            int pro = re.getProbability(), now = Random.Range(0, 100);
                            if (aditional_info.ContainsKey("current"))
                            {
                                aditional_info.Remove("current");
                            }

                            if (pro <= now)
                            {
                                aditional_info.Add("current", "first");
                            }
                            else
                            {
                                aditional_info.Add("current", "second");
                            }

                            forcewait = ((EffectHolderNode)aditional_info [((string)aditional_info ["current"])]).execute();
                        }
                        else
                        {
                            forcewait = ((EffectHolderNode)aditional_info [((string)aditional_info ["current"])]).execute();
                        }

                        break;

                    case EffectType.SET_VALUE:
                        SetValueEffect sve = (SetValueEffect)effect;
                        Game.Instance.GameState.setVariable(sve.getTargetId(), sve.getValue());
                        break;

                    case EffectType.INCREMENT_VAR:
                        IncrementVarEffect ive = (IncrementVarEffect)effect;
                        Game.Instance.GameState.setVariable(ive.getTargetId(), Game.Instance.GameState.getVariable(ive.getTargetId()) + ive.getIncrement());
                        break;

                    case EffectType.DECREMENT_VAR:
                        DecrementVarEffect dve = (DecrementVarEffect)effect;
                        Game.Instance.GameState.setVariable(dve.getTargetId(), Game.Instance.GameState.getVariable(dve.getTargetId()) - dve.getDecrement());
                        break;

                    case EffectType.MACRO_REF:
                        runs_once = false;
                        if (times_runed == 0)
                        {
                            MacroReferenceEffect mre = (MacroReferenceEffect)effect;
                            this.aditional_info.Add("macro", new EffectHolder(Game.Instance.GameState.getMacro(mre.getTargetId())));
                        }
                        forcewait = ((EffectHolder)this.aditional_info ["macro"]).execute();
                        break;

                    case EffectType.MOVE_OBJECT:
                        MoveObjectEffect moe = (MoveObjectEffect)effect;
                        Game.Instance.GameState.Move(moe.getTargetId(), new Vector2(moe.getX(), 600 - moe.getY()) / 10f);
                        break;
                    }
                }
            }
        }

        if (!forcewait)
        {
            times_runed = 0;
        }
        else
        {
            times_runed++;
        }

        return(forcewait);
    }
Exemplo n.º 26
0
 public bool check()
 {
     return(ConditionChecker.check(effect.getConditions()));
 }
Exemplo n.º 27
0
        protected override IEnumerator CreateRoutine(Tile tile, Action <bool> finished)
        {
            var allElements = MapSceneMB.MapElements.FindAll(elem => elem.Conditions == null || ConditionChecker.check(elem.Conditions));

            foreach (var elem in allElements)
            {
                if (!AdoptedElements.Contains(elem) && !OrphanElements.Contains(elem))
                {
                    OrphanElements.Add(elem);
                }
            }

            finished(true);

            yield return(null);
        }
Exemplo n.º 28
0
        protected override IEnumerator UnLoadRoutine(Tile tile, Action <bool> finished)
        {
            var notExisting = MapSceneMB.MapElements.FindAll(elem => elem.Conditions != null && !ConditionChecker.check(elem.Conditions));

            foreach (var elem in notExisting)
            {
                if (OrphanElements.Contains(elem))
                {
                    OrphanElements.Remove(elem);
                }
            }

            finished(true);

            yield return(null);
        }