Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public override void Run_Node()
        {
            if (string.IsNullOrEmpty(actor))
            {
                Debug.LogError("Actor " + actor + " name is null or empty", this.gameObject);
            }
            // Check if the actor is already present
            else if (ActorManager.Is_Actor_On_Scene(actor))
            {
                // Actor is already on the scene
                Actor actor_script = ActorManager.Get_Actor(actor);
                actor_script.position = destination;

                ActorManager.Remove_Actor_From_Positions_Lists(actor_script);
                ActorManager.Add_Actor_To(actor_script, destination);
            }
            else
            {
                Debug.LogError("Actor " + actor + " is not on the scene. Use EnterActorNode to place them on the scene", this.gameObject);
            }

            Finish_Node();
        }