示例#1
0
    // Use this for initialization
    void Start()
    {
        updateResource();
        if (current_resource != null)
        {
            string path = current_resource.getAssetPath(NPC.RESOURCE_TYPE_STAND_UP);

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

            this.gameObject.name = player.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());
    }
示例#2
0
    void Update()
    {
        current_time += Time.deltaTime;

        if (current_time >= update_ratio)
        {
            this.changeFrame();
            this.current_time = 0;
        }

        if (checkingTransparency)
        {
            RaycastHit hit;
            Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit);

            if (current_anim.frames [current_frame].Image.GetPixelBilinear(hit.textureCoord.x, hit.textureCoord.y).a > 0f)
            {
                showHand(true);
            }
            else
            {
                showHand(false);
            }
        }

        if (moving && progress < 1.0f)
        {
            this.transform.localPosition = Vector3.Lerp(start_pos, end_pos, progress);
            Vector2 tmppos = getPosition();
            this.context.setPosition((int)(tmppos.x * 10), (int)((60 - tmppos.y) * 10));
            progress += Time.deltaTime * speed;
        }
        else if (moves.Count > 0)
        {
            move(moves.Dequeue());
        }
        else if (moving && moves.Count <= 0)
        {
            this.current_anim = ResourceManager.Instance.getAnimation(current_resource.getAssetPath(NPC.RESOURCE_TYPE_STAND_UP));
            moving            = false;
        }
    }
 public eAnim getAnimation(string uri)
 {
     if (animations.ContainsKey(uri))
     {
         return(animations [uri]);
     }
     else
     {
         eAnim animation = new eAnim(uri);
         if (animation.Loaded())
         {
             animations.Add(uri, animation);
             return(animation);
         }
         else
         {
             return(null);
         }
     }
 }
示例#4
0
    void move(KeyValuePair <Vector2, float> point)
    {
        moving         = true;
        progress       = 0.0f;
        this.start_pos = this.transform.localPosition;

        Texture2D tmp = current_anim.frames [current_frame].Image;

        this.end_pos = new Vector3(point.Key.x, point.Key.y + ((tmp.height / 10f) * point.Value) / 2, -context.getLayer());

        this.current_frame = 0;
        if (this.start_pos.x < this.end_pos.x)
        {
            this.current_anim = ResourceManager.Instance.getAnimation(current_resource.getAssetPath(NPC.RESOURCE_TYPE_WALK_RIGHT));
        }
        else
        {
            this.current_anim = ResourceManager.Instance.getAnimation(current_resource.getAssetPath(NPC.RESOURCE_TYPE_WALK_LEFT));
        }

        speed = player_speed * (50 / Vector2.Distance(start_pos, end_pos));
    }
示例#5
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;
        }
    }
 public eAnim getAnimation(string uri)
 {
     if (animations.ContainsKey (uri))
         return animations [uri];
     else {
         eAnim animation = new eAnim (Path + uri, type);
         if (animation.Loaded ()) {
             animations.Add (uri, animation);
             return animation;
         } else
             return null;
     }
 }
 protected void LoadAnimation(string uri)
 {
     anim = ResourceManager.Instance.getAnimation(resource.getAssetPath(uri));
 }
示例#8
0
 protected void LoadAnimation(string uri)
 {
     anim = ResourceManager.Instance.getAnimation(resource.getAssetPath(uri));
 }
示例#9
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;
        }
    }