void turnClockwise() {
     inAction = true;
     waitForSeconds(turnSpeed, () => {
         currentForwardDirection = (IsoDirection)(((int)currentForwardDirection + 1) % 4);
         inAction = false;
     });
 }
    void turnCounterclockWise() {
        var newDirectionValue = ((int)currentForwardDirection - 1);
        if (newDirectionValue < 0)
            newDirectionValue += 4;
        newDirectionValue = newDirectionValue % 4;

        inAction = true;
        waitForSeconds(turnSpeed, () => {
            currentForwardDirection = (IsoDirection)newDirectionValue;
            inAction = false;
        });

    }
Пример #3
0
    // Use this for initialization
    void Start() {
        directionA = 1;
        phase1A = true; 
        ORIENTATION_A = IsoDirection.East;

        directionB = 1;
        phase1B = true;
        ORIENTATION_B = IsoDirection.Up;

        directionC = 1;
        phase1C = true;
        ORIENTATION_C = IsoDirection.South;
    }
Пример #4
0
 /// <summary>
 /// returns the isometric projection vector of common directions in isometric space.
 /// </summary>
 /// <param name="dir"> given direction</param>
 /// <returns></returns>
 public static Vector3 vectorToIsoDirection(IsoDirection dir)
 {
     switch (dir) {
         case IsoDirection.North:
             return toIsoProjection(Vector3.right);
         case IsoDirection.East:
             return toIsoProjection(Vector3.down);
         case IsoDirection.South:
             return toIsoProjection(Vector3.left);
         case IsoDirection.West:
             return toIsoProjection(Vector3.up);
         case IsoDirection.Up:
             return toIsoProjection(Vector3.forward);
         case IsoDirection.Down:
             return toIsoProjection(Vector3.back);
         default:
             return Vector2.zero;
     }
 }
Пример #5
0
 /// <summary>
 /// Returns the corresponding, non-isometric Vector of an Isometric direction in regular 3d world space.
 /// Note: For the isometric projection call vectorToisoDirection(IsoDirection dir) or project the returned vector.
 /// </summary>
 /// <param name="dir"></param>
 /// <returns>A non-isometric vector relative to the direction</returns>
 public static Vector3 getVector(IsoDirection dir)
 {
     switch (dir)
     {
         case IsoDirection.North:
             return Vector3.right;
         case IsoDirection.East:
             return Vector3.down;
         case IsoDirection.South:
             return Vector3.left;
         case IsoDirection.West:
             return Vector3.up;
         case IsoDirection.Up:
             return Vector3.forward;
         case IsoDirection.Down:
             return Vector3.back;
         default:
             return Vector2.zero;
     }
 }
Пример #6
0
    //Called by controller (AI or playercontrol)
    public void Move(IsoDirection dir)
    {
        //Initialise vector for grid position
        Vector2 newGridPos = Vector2.zero;

        //Determine new grid position based on direction
        if (dir == IsoDirection.Up)
            newGridPos = new Vector2(currentGridPos.x, currentGridPos.y - 1);
        else if (dir == IsoDirection.Down)
            newGridPos = new Vector2(currentGridPos.x, currentGridPos.y + 1);
        else if (dir == IsoDirection.Left)
            newGridPos = new Vector2(currentGridPos.x - 1, currentGridPos.y);
        else if (dir == IsoDirection.Right)
            newGridPos = new Vector2(currentGridPos.x + 1, currentGridPos.y);

        //If this new grid position can be walked on, and isn't occupied
        if (levelInfo.IsTileWalkable(newGridPos) && !levelInfo.GetTile(newGridPos).isOccupied)
        {
            //Clear previous node
            levelInfo.nodes[(int)currentGridPos.x, (int)currentGridPos.y].Clear();
            //Set current node
            MoveToNode(newGridPos);

            //Set target world position to that of the node at the new grid position
            newPos = levelInfo.GetTile(currentGridPos).worldPosition;

            //If this controller is that of the player, use a player turn
            if (isPlayer)
                GameManager.instance.UsePlayerTurn();

            //If there is a character animation script attached, call the step animation
            if (characterAnimation)
                characterAnimation.Step();
        }
        else
            characterAction.Attack(dir);
    }
Пример #7
0
 public DSCurve[] IsoCurve(IsoDirection isoDirection, double parameter)
 {
     ICurveEntity[] isoLineHosts = SurfaceEntity.GetIsolines((int)isoDirection, parameter);
     return isoLineHosts.ToArray<DSCurve, ICurveEntity>(true);
 }
Пример #8
0
	void MovePlatform_A(GameObject platform) {
		var player = GameObject.FindGameObjectWithTag("Player");
		var offset = 3;
		var offset2 = 8;

		float XD = platform.transform.position.x - player.transform.position.x;
		float YD = platform.transform.position.y - player.transform.position.y;

		if (XD < offset && XD > -offset && YD < offset && YD > -offset) {
			if (waitTimeA == false) {
				player.GetComponent<Rigidbody> ().isKinematic = true;
				player.transform.Translate (Isometric.vectorToIsoDirection (ORIENTATION_A) * directionA * Time.deltaTime);
			}
		} else {
			if (waitTimeA == false) {
				if ((XD > offset2 || XD < -offset2) || (YD > offset2 || YD < -offset2)) {
					player.GetComponent<Rigidbody> ().isKinematic = false;
				}
			}
		}

        if (waitTimeA == false) {
            platform.transform.Translate (Isometric.vectorToIsoDirection (ORIENTATION_A) * directionA * Time.deltaTime);
        }

        if (waitTimeA) {
            delayA++;

            if (delayA > 50) {
                delayA = 0;
                waitTimeA = false;
            }
        }

        // full path not complete, go through first run
        if (pathA == false) {
            // executing first phase (linear path)
            if (phase1A == true) {
                if (waitTimeA == false) {
                    distance1_A++;
                }

                if (distance1_A >= 200) {
                    ORIENTATION_A = IsoDirection.South;
                    phase1A = false;
                    phase2A = true;
                }

            } else if (phase2A) {
                distance2_A++;

                if (distance2_A >= 350) {
                    ORIENTATION_A = IsoDirection.West;
                    phase2A = false;
                    phase3A = true;
                }
            } else if (phase3A) {
                if (waitTimeA == false) {
                    distance3_A++;
                }

                if (distance3_A >= 150) {
                    ORIENTATION_A = IsoDirection.East;

                    // completed path, do reverse
                    pathA = true;
                    waitTimeA = true;
                }
            }
        } else {
            if (phase1A == true) {
                if (waitTimeA == false) {
                    distance1_A--;
                }

                if (distance1_A <= 0) {
                    ORIENTATION_A = IsoDirection.East;

                    // completed path, start over
                    pathA = false;
                    waitTimeA = true;
                }

            } else if (phase2A) {
                distance2_A--;

                if (distance2_A <= 0) {
                    ORIENTATION_A = IsoDirection.West;
                    phase2A = false;
                    phase1A = true;
                }
            } else if (phase3A) {
                if (waitTimeA == false) {
                    distance3_A--;
                }

                if (distance3_A <= 0) {
                    ORIENTATION_A = IsoDirection.North;
                    phase3A = false;
                    phase2A = true;
                }
            }
        }
    }
Пример #9
0
	// Use this for initialization
	void Start () {
		direction = 1;
		ORIENTATION = IsoDirection.Up;
	}
Пример #10
0
	void MovePlatform() {

        GameObject platformA = GameObject.Find("PlatformA-B");
        var player = GameObject.FindGameObjectWithTag("Player");
        var offset = 3;
        var offset2 = 8;


        float XD = transform.position.x - player.transform.position.x;
        float YD = transform.position.y - player.transform.position.y;

        if (XD < offset && XD > -offset && YD < offset && YD > -offset)
        {
            if (waitTime == false)
            {
                player.GetComponent<Rigidbody>().isKinematic = true;
                player.transform.Translate(Isometric.vectorToIsoDirection(ORIENTATION) * direction * Time.deltaTime * speed);
            }
        }
        else {
            if (waitTime == false)
            {
                if ((XD > offset2 || XD < -offset2) || (YD > offset2 || YD < -offset2))
                {
                    player.GetComponent<Rigidbody>().isKinematic = false;
                }
            }
        }




        if (waitTime == false) {
			transform.Translate (Isometric.vectorToIsoDirection (ORIENTATION) * direction * Time.deltaTime * speed);
		}

		if (waitTime) {
			delay++;

			if (delay > 50) {
				delay = 0;
				waitTime = false;
			}
		}

		if (isPathComplete == false) {
			if (phase1 == true) {
				if (waitTime == false) {
					distance1++;
				}

				if (distance1 >= 110) {
					ORIENTATION = IsoDirection.West;
					phase1 = false;
					phase2 = true;
				}
			} else if (phase2) {
				if (waitTime == false) {
					distance2++;
				}

				if (distance2 >= 28) {
					ORIENTATION = IsoDirection.East;

					isPathComplete = true;
					waitTime = true;
				}
			}
		} else {
			if (phase2 == true) {
				if (waitTime == false) {
					distance2--;
				}

				if (distance2 <= 0) {
					ORIENTATION = IsoDirection.North;

					phase2 = false;
					phase1 = true;
				}

			} else if (phase1) {
				if (waitTime == false) {
					distance1--;
				}

				if (distance1 <= 0) {
					ORIENTATION = IsoDirection.South;

					isPathComplete = false;
					waitTime = true;
				}
			}
		}

	}
Пример #11
0
	// Use this for initialization
	void Start () {
		direction = 1;
		speed = 3;
		phase1 = true;
		ORIENTATION = IsoDirection.South;
	}
Пример #12
0
    void MovePlatform()
    {

        GameObject platformA = GameObject.Find("PlatformA-B");
        var player = GameObject.FindGameObjectWithTag("Player");
        var offset = 3;
        var offset2 = 8;


        float XD = transform.position.x - player.transform.position.x;
        float YD = transform.position.y - player.transform.position.y;

        if (XD < offset && XD > -offset && YD < offset && YD > -offset)
        {
            if (waitTime == false)
            {
                player.GetComponent<Rigidbody>().isKinematic = true;
                player.transform.Translate(Isometric.vectorToIsoDirection(ORIENTATION) * direction * Time.deltaTime * speed);
            }
        }
        else {
            if (waitTime == false)
            {
                if ((XD > offset2 || XD < -offset2) || (YD > offset2 || YD < -offset2))
                {
                    player.GetComponent<Rigidbody>().isKinematic = false;
                }
            }
        }




        if (waitTime == false)
        {
            transform.Translate(Isometric.vectorToIsoDirection(ORIENTATION) * direction * Time.deltaTime * speed);
        }

        if (waitTime)
        {
            delay++;

            if (delay > 50)
            {
                delay = 0;
                waitTime = false;
            }
        }

        // full path not complete, go through first run
        if (isPathComplete == false)
        {
            // executing first phase (linear path)
            if (phase1 == true)
            {
                if (waitTime == false)
                {
                    distance1++;
                }

                if (distance1 >= 100)
                {
                    ORIENTATION = IsoDirection.South;
                    phase1 = false;
                    phase2 = true;
                }

            }
            else if (phase2)
            {
                distance2++;

                if (distance2 >= 200)
                {
                    ORIENTATION = IsoDirection.West;
                    phase2 = false;
                    phase3 = true;
                }
            }
            else if (phase3)
            {
                if (waitTime == false)
                {
                    distance3++;
                }

                if (distance3 >= 80)
                {
                    ORIENTATION = IsoDirection.East;

                    // completed path, do reverse
                    isPathComplete = true;
                    waitTime = true;
                }
            }
        }
        else {
            if (phase1 == true)
            {
                if (waitTime == false)
                {
                    distance1--;
                }

                if (distance1 <= 0)
                {
                    ORIENTATION = IsoDirection.East;

                    // completed path, start over
                    isPathComplete = false;
                    waitTime = true;
                }

            }
            else if (phase2)
            {
                distance2--;

                if (distance2 <= 0)
                {
                    ORIENTATION = IsoDirection.West;
                    phase2 = false;
                    phase1 = true;
                }
            }
            else if (phase3)
            {
                if (waitTime == false)
                {
                    distance3--;
                }

                if (distance3 <= 0)
                {
                    ORIENTATION = IsoDirection.North;
                    phase3 = false;
                    phase2 = true;
                }
            }
        }
    }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     direction = 1;
     phase1 = true;
     ORIENTATION = IsoDirection.East;
 }