Example #1
0
        public override VainDrawer CalculateNextPosition(Vain last, Vain next)
        {
            Vector3 position = this.obj.transform.position;

            if (next == exits[1])
            {
                // Leave through bottom
                position += new Vector3(0, 0, size.z);
            }
            else
            {
                // Leave through top
                position += new Vector3(0, 0, size.z);
            }

            return new VainDrawer(position, new Vector3());
        }
Example #2
0
        public override VainDrawer CalculateNextPosition(Vain last, Vain next)
        {
            // Define some variables
            Vector3 position = this.obj.transform.position;
            Vector3 rotation = this.obj.transform.eulerAngles;

            // Check in what direction the vain is placed
            bool flip = this.obj.transform.GetChild(0).transform.forward.z != -1f;
            Vector3 origin = this.obj.transform.position;
            Vector3 far = origin + new Vector3(0f, 0f, this.obj.GetComponentInChildren<MeshFilter>().mesh.bounds.extents.z * 2) * scale;

            Vector3 exit0 = flip ? far : origin;
            Vector3 exit1 = flip ? origin : far;

            //Debug.Log(this.GetID() + " : e0 " + exit0 + " : e1 " + exit1);

            // Check from wich end we are leaving
            if (next == exits[0])
            {
                // We are leaving from the bottom side
                // Set the position to continue on bottom and set the exit position to a calculation from the current vain
                //position = new Vector3(position.x, position.y, position.z - (size.z * this.scale));
                position = exit0;
            }
            else
            {
                // We are leaving from the top side
                // Set the position to continue on top and set the exit position to a calculation from the current vain
                //position = new Vector3(position.x, position.y, position.z + (size.z * this.scale));
                position = exit1;
            }

            Debug.Log(position - origin);

            // Return the information in the VainDrawer format
            return new VainDrawer(position, rotation);
        }
Example #3
0
 public override Vain GetStraight(Vain last)
 {
     if (exits[0] == last)
         return exits[1];
     else
         return exits[0];
 }
Example #4
0
        public override VainDrawer CalculateNextPosition(Vain last, Vain next)
        {
            // Define some variables
            Vector3 position = this.obj.transform.position;
            Vector3 rotation = this.obj.transform.eulerAngles;

            // Check in what direction the vain is placed
            //flip = this.obj.transform.GetChild(0).transform.forward.z != -1f;
            Vector3 origin = this.obj.transform.position;
            Vector3 far = origin + new Vector3(0f, 0f, this.obj.GetComponentInChildren<MeshFilter>().mesh.bounds.extents.z * 2) * scale;

            Vector3 exit0 = flip ? far : origin;
            Vector3 exit1 = (flip ? origin : far) + new Vector3(-0.573125f * scale, 0f, 0f);
            Vector3 exit2 = (flip ? origin : far) + new Vector3(0.5825f * scale, 0f, 0f);

            //Debug.Log("0 : " + exit0);
            //Debug.Log("1 : " + exit1);
            //Debug.Log("2 : " + exit2);

            // Check from wich end we are leaving
            if (next == exits[0])
            {
                // We are leaving from the bottom side
                // Set the position to continue on bottom and set the exit position to a calculation from the current vain
                //if (direction.z == -1f)
                //{
                //    position = new Vector3(position.x, position.y, position.z + (size.z * this.scale));
                //}
                //else
                //{
                //    position = new Vector3(position.x, position.y, position.z);
                //}
                position = exit0;
            }
            else if(next == exits[1])
            {
                // We are leaving from the left top side
                // Set the position to continue on left top and set the exit position to a calculation from the current vain
                //if (direction.z == -1f)
                //{
                //    position = new Vector3(position.x - (0.574f * this.scale), position.y, position.z + (size.z * this.scale));
                //}
                //else
                //{
                //    position = new Vector3(position.x + (0.574f * this.scale), position.y, position.z);
                //}
                position = exit1;
            }
            else
            {
                // We are leaving from the right top side
                // Set the position to continue on right top and set the exit position to a calculation from the current vain
                //if (direction.z == -1f)
                //{
                //    position = new Vector3(position.x + (0.574f * this.scale), position.y, position.z + (size.z * this.scale));
                //}
                //else
                //{
                //    position = new Vector3(position.x - (0.574f * this.scale), position.y, position.z);
                //}
                position = exit2;
            }

            // Return the information in the VainDrawer format
            return new VainDrawer(position, rotation);
        }
Example #5
0
 public override Vain GetStraight(Vain last)
 {
     flip = false;
     // Return the opposite exit of the found one
     if (exits[0] == last)
     {
         // Return the opposite exit from the 0-exit
         return this.exits[1];
     }
     else if (exits[1] == last)
     {
         // Return the opposite exit from the 1-exit or 2-exit
         flip = true;
         return this.exits[0];
     }
     else if(exits[2] == last)
     {
         flip = true;
         return this.exits[0];
     }
     else
     {
         // There is no vain found that had to be drawn
         // This could mean that it is the first vain we are trying to draw
         // Return by default the exit that is not null
         return this.exits[0] == null ? this.exits[1] : this.exits[0];
     }
 }
Example #6
0
        public override Vain GetSecond(Vain last)
        {
            // Find the end of the vain that is already drawn
            int found = -1;
            for (int i = 0; i < exits.Length; i++)
            {
                if (exits[i] == null)
                    continue;
                if (exits[i].IsDrawn())
                {
                    // You found the vain that is drawn at the moment
                    // End your quest
                    found = i;
                    break;
                }
            }

            // Return the opposite exit of the found one
            if (found == 0)
            {
                // Return the opposite exit from the 0-exit
                return this.exits[2];
            }
            else if (found == 1)
            {
                // Return the opposite exit from the 1-exit
                return this.exits[2];
            }
            else if (found == 2)
            {
                // Return the opposite exit from the 2-exit
                return this.exits[1];
            }
            else
            {
                // There is no vain found that had to be drawn
                // This could mean that it is the first vain we are trying to draw
                // Return by default the exit that is not null
                return this.exits[0] == null ? this.exits[1] : this.exits[0];
            }
        }