Beispiel #1
0
 public static RectTransform Get_Side_Position(Actor_Positions position)
 {
     if (position == Actor_Positions.LEFT)
         return left;
     else
         return right;
 }
Beispiel #2
0
        // Instantly places the actor at the designated position
        public void Place_At_Position(Actor_Positions destination)
        {
            position = destination;

            ActorManager.Add_Actor_To(this, destination);
            this.rect = this.GetComponent <RectTransform>();
            this.rect.localPosition = this.desired_position;
        }
Beispiel #3
0
        // Instantiates an actor from the Resources/Actors folder with the name actor_name.
        // It then sets the object as a child of the Actors object in the canvas
        public static Actor Instantiate_Actor(string actor_name, Actor_Positions destination, Transform custom_position = null)
        {
            // Check to see if the actor is already on the scene
            Actor a = ActorManager.Get_Actor(actor_name);

            if (a != null)
            {
                Debug.Log("Actor " + actor_name + " already on scene");
                return(a);
            }
            if (UIManager.ui_manager.actor_parent == null)
            {
                Debug.LogError("Unable to instantiate Actor " + actor_name + " because UIManager's actor_parent field is empty. Please set actor_parent field to an object.");
            }


            // Check if there is a disabled actor available to use
            if (use_inactive_actors)
            {
                Actor[] disabled_actors = UIManager.ui_manager.actor_parent.gameObject.GetComponentsInChildren <Actor>(true);
                foreach (Actor acto in disabled_actors)
                {
                    if (acto.actor_name == actor_name)
                    {
                        // Found a correct actor, set it up correctly
                        a = acto;
                        a.Reset();
                        a.gameObject.SetActive(true);
                    }
                }
            }


            if (a == null)
            {
                // Proceed with creating a gameobject
                GameObject actor = Instantiate(Resources.Load("Actors/" + actor_name, typeof(GameObject)), UIManager.ui_manager.actor_parent) as GameObject;
                a = actor.GetComponent <Actor>();
            }

            actors_on_scene.Add(a);  // Add to list of actors

            // Place actor at custom position
            if (destination == Actor_Positions.CUSTOM && custom_position != null)
            {
                //a.rect.localPosition = custom_position.position;
                a.desired_position = new Vector3(custom_position.GetComponent <RectTransform>().localPosition.x,
                                                 custom_position.GetComponent <RectTransform>().localPosition.y *a.transform.localScale.y);
                a.custom_position = custom_position;
            }
            // Use standard automatic position calculations
            else
            {
                ActorManager.Add_Actor_To(a, destination);
            }

            return(a);
        }
Beispiel #4
0
    // Calls a coroutine to slide in this actor over a number of seconds specified by over_time
    public void Slide_In(Actor_Positions destination, float over_time)
    {
        rect = GetComponent<RectTransform>();

        ActorManager.Add_Actor_To(this, destination);

        // Set our starting point so we slide into our desired position
        ActorManager.actor_manager.Slide_Start_Position(this, position);
    }
Beispiel #5
0
    // Instantly places the actor at the designated position
    public void Place_At_Position(Actor_Positions destination)
    {
        Debug.Log("Placing actor at position");
        position = destination;

        ActorManager.Add_Actor_To(this, destination);
        this.rect = this.GetComponent<RectTransform>();
        this.rect.localPosition = this.desired_position;
    }
Beispiel #6
0
        // Calls a coroutine to slide in this actor over a number of seconds specified by over_time
        public void Slide_In(Actor_Positions destination, float over_time)
        {
            rect = GetComponent <RectTransform>();

            ActorManager.Add_Actor_To(this, destination);

            // Set our starting point so we slide into our desired position
            ActorManager.actor_manager.Slide_Start_Position(this, position);
        }
Beispiel #7
0
        public void Slide_Start_Position(Actor actor, Actor_Positions position)
        {
            RectTransform rect = actor.GetComponent <RectTransform>();

            if (position == Actor_Positions.LEFT)
            {
                rect.localPosition = offscreen_left.localPosition;
            }
            else if (position == Actor_Positions.RIGHT)
            {
                rect.localPosition = offscreen_right.localPosition;
            }
            else if (position == Actor_Positions.CENTER || position == Actor_Positions.CUSTOM)
            {
                rect.localPosition = offscreen_right.localPosition;
            }

            rect.localPosition = new Vector3(rect.localPosition.x,
                                             0, //ActorManager.Get_Actor_Y_Position(actor),
                                             rect.localPosition.z);
        }
Beispiel #8
0
        public static void Add_Actor_To(Actor actor, Actor_Positions position)
        {
            actor.position = position;
            List <Actor> side_list = null;

            switch (position)
            {
            case (Actor_Positions.LEFT):
                side_list = left_actors;
                break;

            case (Actor_Positions.RIGHT):
                side_list = right_actors;
                break;

            case (Actor_Positions.CENTER):
                side_list = center_actors;
                break;

            case (Actor_Positions.CUSTOM):
                // Custom positions don't have a side list
                return;
            }

            // If actor is already present on that side, do nothing
            if (side_list.Contains(actor))
            {
                return;
            }

            // Actors are added starting from the edge, working their way in
            side_list.Add(actor);

            // Set their position on the screen
            Reevaluate_All_Actor_Positions();
        }
Beispiel #9
0
    // Instantiates an actor from the Resources/Actors folder with the name actor_name.
    // It then sets the object as a child of the Actors object in the canvas
    public static Actor Instantiate_Actor(string actor_name, Actor_Positions destination)
    {
        // Check to see if the actor is already on the scene
        Actor a = ActorManager.Get_Actor(actor_name);
        if (a != null)
        {
            Debug.Log("Actor " + actor_name + " already on scene");
            return a;
        }

        // Proceed with creating a gameobject
        GameObject actor = Instantiate(Resources.Load("Actors/" + actor_name, typeof(GameObject))) as GameObject;
        actor.transform.SetParent(GameObject.Find(VNProperties.canvas_name + "/Actors").transform, false);
        //actor.transform.localScale = Vector3.one;

        Actor actor_script = actor.GetComponent<Actor>();
        actors_on_scene.Add(actor_script);  // Add to list of actors

        ActorManager.Add_Actor_To(actor_script, destination);
        
        return actor_script;
    }
Beispiel #10
0
 // Returns the RectTransform positions of an actor position
 public static RectTransform Get_Position(Actor_Positions position)
 {
     return GameObject.Find(VNProperties.canvas_name + "/ActorPositions/" + Enum.GetName(typeof(Actor_Positions), position)).GetComponent<RectTransform>();
 }
Beispiel #11
0
    public void Slide_Start_Position(Actor actor, Actor_Positions position)
    {
        RectTransform rect = actor.GetComponent<RectTransform>();

        if (position == Actor_Positions.LEFT)
            rect.localPosition = offscreen_left.localPosition;
        if (position == Actor_Positions.RIGHT)
            rect.localPosition = offscreen_right.localPosition;

        rect.localPosition = new Vector3(rect.localPosition.x, ActorManager.Get_Actor_Y_Position(actor), rect.localPosition.z);
    }
Beispiel #12
0
    public static void Add_Actor_To(Actor actor, Actor_Positions position)
    {
        actor.position = position;
        List<Actor> side_list = null;

        switch (position)
        {
            case (Actor_Positions.LEFT):
                side_list = left_actors;
                break;
            case (Actor_Positions.RIGHT):
                side_list = right_actors;
                break;
        }

        // If actor is already present on that side, do nothing
        if (side_list.Contains(actor))
        {
            return;
        }

        // Actors are added starting from the edge, working their way in
        side_list.Add(actor);

        // Set their position on the screen
        Reevaluate_All_Actor_Positions();
    }
Beispiel #13
0
    // Instantiates an actor from the Resources/Actors folder with the name actor_name.
    // It then sets the object as a child of the Actors object in the canvas
    public static Actor Instantiate_Actor(string actor_name, Actor_Positions destination)
    {
        GameObject actor = Instantiate(Resources.Load("VN Engine/Actors/" + actor_name, typeof(GameObject))) as GameObject;
        actor.transform.SetParent(GameObject.Find(VNProperties.canvas_name + "/Actors").transform, false);
        //actor.transform.localScale = Vector3.one;

        Actor actor_script = actor.GetComponent<Actor>();
        actors_on_scene.Add(actor_script);  // Add to list of actors

        return actor_script;
    }