Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraMod
- {
- public int xMinimum, yMinimum, xMaximum, yMaximum, xCurrentPos, yCurrentPos, xTruePos, yTruePos, xScreenWidth, yScreenWidth;
- public bool localMPCamera = false;
- public CameraMod(bool isMultiplayer, int xMin, int yMin, int width, int height, int xStart, int yStart, int xResolution, int yResolution)
- {
- localMPCamera = isMultiplayer;
- xMinimum = xMin;
- yMinimum = yMin;
- xMaximum = width;
- yMaximum = height;
- xCurrentPos = xStart;
- yCurrentPos = yStart;
- xTruePos = xStart;
- yTruePos = yStart;
- xScreenWidth = xResolution / 2;
- yScreenWidth = yResolution / 2;
- }
- public void MoveCamera(int p1X, int p1Y, int p2X, int p2Y, int p3X, int p3Y, int p4X, int p4Y, int anchorX, int anchorY, int numberOfPlayers, int adjustX, int adjustY)
- {
- if (numberOfPlayers <= 1)
- {
- #region set truepos
- if (p1X > xMinimum && p1X < xMaximum)
- {
- xTruePos = (p1X - (xScreenWidth - adjustX));
- }
- if (p1Y > yMinimum && p1Y < yMaximum)
- {
- yTruePos = (p1Y - (yScreenWidth - adjustY));
- }
- #endregion
- }
- else if (numberOfPlayers == 2)
- {
- #region set truepos
- if ((p1X + p1X + p2X) / 3 > xMinimum && (p1X + p1X + p2X) / 3 < xMaximum)
- {
- xTruePos = (((p1X + p1X + p2X) / 3) - (xScreenWidth - adjustX));
- }
- if ((p1Y + p1Y + p2Y) / 3 > yMinimum && (p1Y + p1Y + p2Y) / 3 < yMaximum)
- {
- yTruePos = (((p1Y + p1Y + p2Y) / 3) - (yScreenWidth - adjustY));
- }
- #endregion
- }
- else if (numberOfPlayers == 3)
- {
- #region set truepos
- if ((p1X + p1X + p2X + p3X) / 4 > xMinimum && (p1X + p1X + p2X + p3X) / 4 < xMaximum)
- {
- xTruePos = (((p1X + p1X + p2X + p3X) / 4) - (xScreenWidth - adjustX));
- }
- if ((p1Y + p1Y + p2Y + p3Y) / 4 > yMinimum && (p1Y + p1Y + p2Y + p3Y) / 4 < yMaximum)
- {
- yTruePos = (((p1Y + p1Y + p2Y + p3Y) / 4) - (yScreenWidth - adjustY));
- }
- #endregion
- }
- else if (numberOfPlayers >= 4)
- {
- #region set truepos
- if ((p1X + p1X + p2X + p3X + p4X) / 5 > xMinimum && (p1X + p1X + p2X + p3X + p4X) / 5 < xMaximum)
- {
- xTruePos = (((p1X + p1X + p2X + p3X + p4X) / 5) - (xScreenWidth - adjustX));
- }
- if ((p1Y + p1Y + p2Y + p3Y + p4Y) / 5 > yMinimum && (p1Y + p1Y + p2Y + p3Y + p4Y) / 5 < yMaximum)
- {
- yTruePos = (((p1Y + p1Y + p2Y + p3Y + p4Y) / 5) - (yScreenWidth - adjustY));
- }
- #endregion
- }
- #region trail currentpos
- if (xCurrentPos != xTruePos)
- {
- #region x-axis
- if (xCurrentPos < xTruePos)
- {
- if (xTruePos - xCurrentPos <= 5)
- {
- xCurrentPos += 1;
- }
- if (xTruePos - xCurrentPos <= 10 && xTruePos - xCurrentPos > 5)
- {
- xCurrentPos += 2;
- }
- if (xTruePos - xCurrentPos <= 20 && xTruePos - xCurrentPos > 10)
- {
- xCurrentPos += 3;
- }
- if (xTruePos - xCurrentPos <= 30 && xTruePos - xCurrentPos > 20)
- {
- xCurrentPos += 4;
- }
- if (xTruePos - xCurrentPos <= 40 && xTruePos - xCurrentPos > 30)
- {
- xCurrentPos += 5;
- }
- if (xTruePos - xCurrentPos <= 50 && xTruePos - xCurrentPos > 40)
- {
- xCurrentPos += 6;
- }
- if (xTruePos - xCurrentPos <= 60 && xTruePos - xCurrentPos > 50)
- {
- xCurrentPos += 7;
- }
- if (xTruePos - xCurrentPos <= 70 && xTruePos - xCurrentPos > 60)
- {
- xCurrentPos += 8;
- }
- if (xTruePos - xCurrentPos <= 80 && xTruePos - xCurrentPos > 70)
- {
- xCurrentPos += 9;
- }
- if (xTruePos - xCurrentPos <= 90 && xTruePos - xCurrentPos > 80)
- {
- xCurrentPos += 10;
- }
- if (xTruePos - xCurrentPos <= 100 && xTruePos - xCurrentPos > 90)
- {
- xCurrentPos += 11;
- }
- if (xTruePos - xCurrentPos <= 110 && xTruePos - xCurrentPos > 100)
- {
- xCurrentPos += 12;
- }
- if (xTruePos - xCurrentPos <= 120 && xTruePos - xCurrentPos > 110)
- {
- xCurrentPos += 13;
- }
- if (xTruePos - xCurrentPos <= 130 && xTruePos - xCurrentPos > 120)
- {
- xCurrentPos += 14;
- }
- if (xTruePos - xCurrentPos <= 140 && xTruePos - xCurrentPos > 130)
- {
- xCurrentPos += 15;
- }
- if (xTruePos - xCurrentPos <= 150 && xTruePos - xCurrentPos > 140)
- {
- xCurrentPos += 16;
- }
- if (xTruePos - xCurrentPos <= 160 && xTruePos - xCurrentPos > 150)
- {
- xCurrentPos += 17;
- }
- if (xTruePos - xCurrentPos <= 170 && xTruePos - xCurrentPos > 160)
- {
- xCurrentPos += 18;
- }
- if (xTruePos - xCurrentPos <= 180 && xTruePos - xCurrentPos > 170)
- {
- xCurrentPos += 19;
- }
- if (xTruePos - xCurrentPos <= 190 && xTruePos - xCurrentPos > 180)
- {
- xCurrentPos += 20;
- }
- if (xTruePos - xCurrentPos > 190)
- {
- xCurrentPos += 21;
- }
- }
- if (xCurrentPos > xTruePos)
- {
- if (xCurrentPos - xTruePos <= 5)
- {
- xCurrentPos -= 1;
- }
- if (xCurrentPos - xTruePos <= 10 && xCurrentPos - xTruePos > 5)
- {
- xCurrentPos -= 2;
- }
- if (xCurrentPos - xTruePos <= 20 && xCurrentPos - xTruePos > 10)
- {
- xCurrentPos -= 3;
- }
- if (xCurrentPos - xTruePos <= 30 && xCurrentPos - xTruePos > 20)
- {
- xCurrentPos -= 4;
- }
- if (xCurrentPos - xTruePos <= 40 && xCurrentPos - xTruePos > 30)
- {
- xCurrentPos -= 5;
- }
- if (xCurrentPos - xTruePos <= 50 && xCurrentPos - xTruePos > 40)
- {
- xCurrentPos -= 6;
- }
- if (xCurrentPos - xTruePos <= 60 && xCurrentPos - xTruePos > 50)
- {
- xCurrentPos -= 7;
- }
- if (xCurrentPos - xTruePos <= 70 && xCurrentPos - xTruePos > 60)
- {
- xCurrentPos -= 8;
- }
- if (xCurrentPos - xTruePos <= 80 && xCurrentPos - xTruePos > 70)
- {
- xCurrentPos -= 9;
- }
- if (xCurrentPos - xTruePos <= 90 && xCurrentPos - xTruePos > 80)
- {
- xCurrentPos -= 10;
- }
- if (xCurrentPos - xTruePos <= 100 && xCurrentPos - xTruePos > 90)
- {
- xCurrentPos -= 11;
- }
- if (xCurrentPos - xTruePos <= 110 && xCurrentPos - xTruePos > 100)
- {
- xCurrentPos -= 12;
- }
- if (xCurrentPos - xTruePos <= 120 && xCurrentPos - xTruePos > 110)
- {
- xCurrentPos -= 13;
- }
- if (xCurrentPos - xTruePos <= 130 && xCurrentPos - xTruePos > 120)
- {
- xCurrentPos -= 14;
- }
- if (xCurrentPos - xTruePos <= 140 && xCurrentPos - xTruePos > 130)
- {
- xCurrentPos -= 15;
- }
- if (xCurrentPos - xTruePos <= 150 && xCurrentPos - xTruePos > 140)
- {
- xCurrentPos -= 16;
- }
- if (xCurrentPos - xTruePos <= 160 && xCurrentPos - xTruePos > 150)
- {
- xCurrentPos -= 17;
- }
- if (xCurrentPos - xTruePos <= 170 && xCurrentPos - xTruePos > 160)
- {
- xCurrentPos -= 18;
- }
- if (xCurrentPos - xTruePos <= 180 && xCurrentPos - xTruePos > 170)
- {
- xCurrentPos -= 19;
- }
- if (xCurrentPos - xTruePos <= 190 && xCurrentPos - xTruePos > 180)
- {
- xCurrentPos -= 20;
- }
- if (xCurrentPos - xTruePos > 190)
- {
- xCurrentPos -= 21;
- }
- }
- #endregion
- }
- if (yCurrentPos != yTruePos)
- {
- #region y-ayis
- if (yCurrentPos < yTruePos)
- {
- if (yTruePos - yCurrentPos <= 5)
- {
- yCurrentPos += 1;
- }
- if (yTruePos - yCurrentPos <= 10 && yTruePos - yCurrentPos > 5)
- {
- yCurrentPos += 2;
- }
- if (yTruePos - yCurrentPos <= 20 && yTruePos - yCurrentPos > 10)
- {
- yCurrentPos += 3;
- }
- if (yTruePos - yCurrentPos <= 30 && yTruePos - yCurrentPos > 20)
- {
- yCurrentPos += 4;
- }
- if (yTruePos - yCurrentPos <= 40 && yTruePos - yCurrentPos > 30)
- {
- yCurrentPos += 5;
- }
- if (yTruePos - yCurrentPos <= 50 && yTruePos - yCurrentPos > 40)
- {
- yCurrentPos += 6;
- }
- if (yTruePos - yCurrentPos <= 60 && yTruePos - yCurrentPos > 50)
- {
- yCurrentPos += 7;
- }
- if (yTruePos - yCurrentPos <= 70 && yTruePos - yCurrentPos > 60)
- {
- yCurrentPos += 8;
- }
- if (yTruePos - yCurrentPos <= 80 && yTruePos - yCurrentPos > 70)
- {
- yCurrentPos += 9;
- }
- if (yTruePos - yCurrentPos <= 90 && yTruePos - yCurrentPos > 80)
- {
- yCurrentPos += 10;
- }
- if (yTruePos - yCurrentPos <= 100 && yTruePos - yCurrentPos > 90)
- {
- yCurrentPos += 11;
- }
- if (yTruePos - yCurrentPos <= 110 && yTruePos - yCurrentPos > 100)
- {
- yCurrentPos += 12;
- }
- if (yTruePos - yCurrentPos <= 120 && yTruePos - yCurrentPos > 110)
- {
- yCurrentPos += 13;
- }
- if (yTruePos - yCurrentPos <= 130 && yTruePos - yCurrentPos > 120)
- {
- yCurrentPos += 14;
- }
- if (yTruePos - yCurrentPos <= 140 && yTruePos - yCurrentPos > 130)
- {
- yCurrentPos += 15;
- }
- if (yTruePos - yCurrentPos <= 150 && yTruePos - yCurrentPos > 140)
- {
- yCurrentPos += 16;
- }
- if (yTruePos - yCurrentPos <= 160 && yTruePos - yCurrentPos > 150)
- {
- yCurrentPos += 17;
- }
- if (yTruePos - yCurrentPos <= 170 && yTruePos - yCurrentPos > 160)
- {
- yCurrentPos += 18;
- }
- if (yTruePos - yCurrentPos <= 180 && yTruePos - yCurrentPos > 170)
- {
- yCurrentPos += 19;
- }
- if (yTruePos - yCurrentPos <= 190 && yTruePos - yCurrentPos > 180)
- {
- yCurrentPos += 20;
- }
- if (yTruePos - yCurrentPos > 190)
- {
- yCurrentPos += 21;
- }
- }
- if (yCurrentPos > yTruePos)
- {
- if (yCurrentPos - yTruePos <= 5)
- {
- yCurrentPos -= 1;
- }
- if (yCurrentPos - yTruePos <= 10 && yCurrentPos - yTruePos > 5)
- {
- yCurrentPos -= 2;
- }
- if (yCurrentPos - yTruePos <= 20 && yCurrentPos - yTruePos > 10)
- {
- yCurrentPos -= 3;
- }
- if (yCurrentPos - yTruePos <= 30 && yCurrentPos - yTruePos > 20)
- {
- yCurrentPos -= 4;
- }
- if (yCurrentPos - yTruePos <= 40 && yCurrentPos - yTruePos > 30)
- {
- yCurrentPos -= 5;
- }
- if (yCurrentPos - yTruePos <= 50 && yCurrentPos - yTruePos > 40)
- {
- yCurrentPos -= 6;
- }
- if (yCurrentPos - yTruePos <= 60 && yCurrentPos - yTruePos > 50)
- {
- yCurrentPos -= 7;
- }
- if (yCurrentPos - yTruePos <= 70 && yCurrentPos - yTruePos > 60)
- {
- yCurrentPos -= 8;
- }
- if (yCurrentPos - yTruePos <= 80 && yCurrentPos - yTruePos > 70)
- {
- yCurrentPos -= 9;
- }
- if (yCurrentPos - yTruePos <= 90 && yCurrentPos - yTruePos > 80)
- {
- yCurrentPos -= 10;
- }
- if (yCurrentPos - yTruePos <= 100 && yCurrentPos - yTruePos > 90)
- {
- yCurrentPos -= 11;
- }
- if (yCurrentPos - yTruePos <= 110 && yCurrentPos - yTruePos > 100)
- {
- yCurrentPos -= 12;
- }
- if (yCurrentPos - yTruePos <= 120 && yCurrentPos - yTruePos > 110)
- {
- yCurrentPos -= 13;
- }
- if (yCurrentPos - yTruePos <= 130 && yCurrentPos - yTruePos > 120)
- {
- yCurrentPos -= 14;
- }
- if (yCurrentPos - yTruePos <= 140 && yCurrentPos - yTruePos > 130)
- {
- yCurrentPos -= 15;
- }
- if (yCurrentPos - yTruePos <= 150 && yCurrentPos - yTruePos > 140)
- {
- yCurrentPos -= 16;
- }
- if (yCurrentPos - yTruePos <= 160 && yCurrentPos - yTruePos > 150)
- {
- yCurrentPos -= 17;
- }
- if (yCurrentPos - yTruePos <= 170 && yCurrentPos - yTruePos > 160)
- {
- yCurrentPos -= 18;
- }
- if (yCurrentPos - yTruePos <= 180 && yCurrentPos - yTruePos > 170)
- {
- yCurrentPos -= 19;
- }
- if (yCurrentPos - yTruePos <= 190 && yCurrentPos - yTruePos > 180)
- {
- yCurrentPos -= 20;
- }
- if (yCurrentPos - yTruePos > 190)
- {
- yCurrentPos -= 21;
- }
- }
- #endregion
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement