Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 16.45 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5.  
  6. public class CameraMod
  7. {
  8.     public int xMinimum, yMinimum, xMaximum, yMaximum, xCurrentPos, yCurrentPos, xTruePos, yTruePos, xScreenWidth, yScreenWidth;
  9.     public bool localMPCamera = false;
  10.  
  11.     public CameraMod(bool isMultiplayer, int xMin, int yMin, int width, int height, int xStart, int yStart, int xResolution, int yResolution)
  12.     {
  13.         localMPCamera = isMultiplayer;
  14.         xMinimum = xMin;
  15.         yMinimum = yMin;
  16.         xMaximum = width;
  17.         yMaximum = height;
  18.         xCurrentPos = xStart;
  19.         yCurrentPos = yStart;
  20.         xTruePos = xStart;
  21.         yTruePos = yStart;
  22.         xScreenWidth = xResolution / 2;
  23.         yScreenWidth = yResolution / 2;
  24.     }
  25.  
  26.     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)
  27.     {
  28.         if (numberOfPlayers <= 1)
  29.         {
  30.             #region set truepos
  31.             if (p1X > xMinimum && p1X < xMaximum)
  32.             {
  33.                 xTruePos = (p1X - (xScreenWidth - adjustX));
  34.             }
  35.  
  36.             if (p1Y > yMinimum && p1Y < yMaximum)
  37.             {
  38.                 yTruePos = (p1Y - (yScreenWidth - adjustY));
  39.             }
  40.             #endregion
  41.         }
  42.         else if (numberOfPlayers == 2)
  43.         {
  44.             #region set truepos
  45.             if ((p1X + p1X + p2X) / 3 > xMinimum && (p1X + p1X + p2X) / 3 < xMaximum)
  46.             {
  47.                 xTruePos = (((p1X + p1X + p2X) / 3) - (xScreenWidth - adjustX));
  48.             }
  49.  
  50.             if ((p1Y + p1Y + p2Y) / 3 > yMinimum && (p1Y + p1Y + p2Y) / 3 < yMaximum)
  51.             {
  52.                 yTruePos = (((p1Y + p1Y + p2Y) / 3) - (yScreenWidth - adjustY));
  53.             }
  54.             #endregion
  55.         }
  56.         else if (numberOfPlayers == 3)
  57.         {
  58.             #region set truepos
  59.             if ((p1X + p1X + p2X + p3X) / 4 > xMinimum && (p1X + p1X + p2X + p3X) / 4 < xMaximum)
  60.             {
  61.                 xTruePos = (((p1X + p1X + p2X + p3X) / 4) - (xScreenWidth - adjustX));
  62.             }
  63.  
  64.             if ((p1Y + p1Y + p2Y + p3Y) / 4 > yMinimum && (p1Y + p1Y + p2Y + p3Y) / 4 < yMaximum)
  65.             {
  66.                 yTruePos = (((p1Y + p1Y + p2Y + p3Y) / 4) - (yScreenWidth - adjustY));
  67.             }
  68.             #endregion
  69.         }
  70.         else if (numberOfPlayers >= 4)
  71.         {
  72.             #region set truepos
  73.             if ((p1X + p1X + p2X + p3X + p4X) / 5 > xMinimum && (p1X + p1X + p2X + p3X + p4X) / 5 < xMaximum)
  74.             {
  75.                 xTruePos = (((p1X + p1X + p2X + p3X + p4X) / 5) - (xScreenWidth - adjustX));
  76.             }
  77.  
  78.             if ((p1Y + p1Y + p2Y + p3Y + p4Y) / 5 > yMinimum && (p1Y + p1Y + p2Y + p3Y + p4Y) / 5 < yMaximum)
  79.             {
  80.                 yTruePos = (((p1Y + p1Y + p2Y + p3Y + p4Y) / 5) - (yScreenWidth - adjustY));
  81.             }
  82.             #endregion
  83.         }
  84.  
  85.         #region trail currentpos
  86.         if (xCurrentPos != xTruePos)
  87.         {
  88.             #region x-axis
  89.             if (xCurrentPos < xTruePos)
  90.             {
  91.                 if (xTruePos - xCurrentPos <= 5)
  92.                 {
  93.                     xCurrentPos += 1;
  94.                 }
  95.                 if (xTruePos - xCurrentPos <= 10 && xTruePos - xCurrentPos > 5)
  96.                 {
  97.                     xCurrentPos += 2;
  98.                 }
  99.                 if (xTruePos - xCurrentPos <= 20 && xTruePos - xCurrentPos > 10)
  100.                 {
  101.                     xCurrentPos += 3;
  102.                 }
  103.                 if (xTruePos - xCurrentPos <= 30 && xTruePos - xCurrentPos > 20)
  104.                 {
  105.                     xCurrentPos += 4;
  106.                 }
  107.                 if (xTruePos - xCurrentPos <= 40 && xTruePos - xCurrentPos > 30)
  108.                 {
  109.                     xCurrentPos += 5;
  110.                 }
  111.                 if (xTruePos - xCurrentPos <= 50 && xTruePos - xCurrentPos > 40)
  112.                 {
  113.                     xCurrentPos += 6;
  114.                 }
  115.                 if (xTruePos - xCurrentPos <= 60 && xTruePos - xCurrentPos > 50)
  116.                 {
  117.                     xCurrentPos += 7;
  118.                 }
  119.                 if (xTruePos - xCurrentPos <= 70 && xTruePos - xCurrentPos > 60)
  120.                 {
  121.                     xCurrentPos += 8;
  122.                 }
  123.                 if (xTruePos - xCurrentPos <= 80 && xTruePos - xCurrentPos > 70)
  124.                 {
  125.                     xCurrentPos += 9;
  126.                 }
  127.                 if (xTruePos - xCurrentPos <= 90 && xTruePos - xCurrentPos > 80)
  128.                 {
  129.                     xCurrentPos += 10;
  130.                 }
  131.                 if (xTruePos - xCurrentPos <= 100 && xTruePos - xCurrentPos > 90)
  132.                 {
  133.                     xCurrentPos += 11;
  134.                 }
  135.                 if (xTruePos - xCurrentPos <= 110 && xTruePos - xCurrentPos > 100)
  136.                 {
  137.                     xCurrentPos += 12;
  138.                 }
  139.                 if (xTruePos - xCurrentPos <= 120 && xTruePos - xCurrentPos > 110)
  140.                 {
  141.                     xCurrentPos += 13;
  142.                 }
  143.                 if (xTruePos - xCurrentPos <= 130 && xTruePos - xCurrentPos > 120)
  144.                 {
  145.                     xCurrentPos += 14;
  146.                 }
  147.                 if (xTruePos - xCurrentPos <= 140 && xTruePos - xCurrentPos > 130)
  148.                 {
  149.                     xCurrentPos += 15;
  150.                 }
  151.                 if (xTruePos - xCurrentPos <= 150 && xTruePos - xCurrentPos > 140)
  152.                 {
  153.                     xCurrentPos += 16;
  154.                 }
  155.                 if (xTruePos - xCurrentPos <= 160 && xTruePos - xCurrentPos > 150)
  156.                 {
  157.                     xCurrentPos += 17;
  158.                 }
  159.                 if (xTruePos - xCurrentPos <= 170 && xTruePos - xCurrentPos > 160)
  160.                 {
  161.                     xCurrentPos += 18;
  162.                 }
  163.                 if (xTruePos - xCurrentPos <= 180 && xTruePos - xCurrentPos > 170)
  164.                 {
  165.                     xCurrentPos += 19;
  166.                 }
  167.                 if (xTruePos - xCurrentPos <= 190 && xTruePos - xCurrentPos > 180)
  168.                 {
  169.                     xCurrentPos += 20;
  170.                 }
  171.                 if (xTruePos - xCurrentPos > 190)
  172.                 {
  173.                     xCurrentPos += 21;
  174.                 }
  175.             }
  176.             if (xCurrentPos > xTruePos)
  177.             {
  178.                 if (xCurrentPos - xTruePos <= 5)
  179.                 {
  180.                     xCurrentPos -= 1;
  181.                 }
  182.                 if (xCurrentPos - xTruePos <= 10 && xCurrentPos - xTruePos > 5)
  183.                 {
  184.                     xCurrentPos -= 2;
  185.                 }
  186.                 if (xCurrentPos - xTruePos <= 20 && xCurrentPos - xTruePos > 10)
  187.                 {
  188.                     xCurrentPos -= 3;
  189.                 }
  190.                 if (xCurrentPos - xTruePos <= 30 && xCurrentPos - xTruePos > 20)
  191.                 {
  192.                     xCurrentPos -= 4;
  193.                 }
  194.                 if (xCurrentPos - xTruePos <= 40 && xCurrentPos - xTruePos > 30)
  195.                 {
  196.                     xCurrentPos -= 5;
  197.                 }
  198.                 if (xCurrentPos - xTruePos <= 50 && xCurrentPos - xTruePos > 40)
  199.                 {
  200.                     xCurrentPos -= 6;
  201.                 }
  202.                 if (xCurrentPos - xTruePos <= 60 && xCurrentPos - xTruePos > 50)
  203.                 {
  204.                     xCurrentPos -= 7;
  205.                 }
  206.                 if (xCurrentPos - xTruePos <= 70 && xCurrentPos - xTruePos > 60)
  207.                 {
  208.                     xCurrentPos -= 8;
  209.                 }
  210.                 if (xCurrentPos - xTruePos <= 80 && xCurrentPos - xTruePos > 70)
  211.                 {
  212.                     xCurrentPos -= 9;
  213.                 }
  214.                 if (xCurrentPos - xTruePos <= 90 && xCurrentPos - xTruePos > 80)
  215.                 {
  216.                     xCurrentPos -= 10;
  217.                 }
  218.                 if (xCurrentPos - xTruePos <= 100 && xCurrentPos - xTruePos > 90)
  219.                 {
  220.                     xCurrentPos -= 11;
  221.                 }
  222.                 if (xCurrentPos - xTruePos <= 110 && xCurrentPos - xTruePos > 100)
  223.                 {
  224.                     xCurrentPos -= 12;
  225.                 }
  226.                 if (xCurrentPos - xTruePos <= 120 && xCurrentPos - xTruePos > 110)
  227.                 {
  228.                     xCurrentPos -= 13;
  229.                 }
  230.                 if (xCurrentPos - xTruePos <= 130 && xCurrentPos - xTruePos > 120)
  231.                 {
  232.                     xCurrentPos -= 14;
  233.                 }
  234.                 if (xCurrentPos - xTruePos <= 140 && xCurrentPos - xTruePos > 130)
  235.                 {
  236.                     xCurrentPos -= 15;
  237.                 }
  238.                 if (xCurrentPos - xTruePos <= 150 && xCurrentPos - xTruePos > 140)
  239.                 {
  240.                     xCurrentPos -= 16;
  241.                 }
  242.                 if (xCurrentPos - xTruePos <= 160 && xCurrentPos - xTruePos > 150)
  243.                 {
  244.                     xCurrentPos -= 17;
  245.                 }
  246.                 if (xCurrentPos - xTruePos <= 170 && xCurrentPos - xTruePos > 160)
  247.                 {
  248.                     xCurrentPos -= 18;
  249.                 }
  250.                 if (xCurrentPos - xTruePos <= 180 && xCurrentPos - xTruePos > 170)
  251.                 {
  252.                     xCurrentPos -= 19;
  253.                 }
  254.                 if (xCurrentPos - xTruePos <= 190 && xCurrentPos - xTruePos > 180)
  255.                 {
  256.                     xCurrentPos -= 20;
  257.                 }
  258.                 if (xCurrentPos - xTruePos > 190)
  259.                 {
  260.                     xCurrentPos -= 21;
  261.                 }
  262.             }
  263.             #endregion
  264.         }
  265.  
  266.         if (yCurrentPos != yTruePos)
  267.         {
  268.             #region y-ayis
  269.             if (yCurrentPos < yTruePos)
  270.             {
  271.                 if (yTruePos - yCurrentPos <= 5)
  272.                 {
  273.                     yCurrentPos += 1;
  274.                 }
  275.                 if (yTruePos - yCurrentPos <= 10 && yTruePos - yCurrentPos > 5)
  276.                 {
  277.                     yCurrentPos += 2;
  278.                 }
  279.                 if (yTruePos - yCurrentPos <= 20 && yTruePos - yCurrentPos > 10)
  280.                 {
  281.                     yCurrentPos += 3;
  282.                 }
  283.                 if (yTruePos - yCurrentPos <= 30 && yTruePos - yCurrentPos > 20)
  284.                 {
  285.                     yCurrentPos += 4;
  286.                 }
  287.                 if (yTruePos - yCurrentPos <= 40 && yTruePos - yCurrentPos > 30)
  288.                 {
  289.                     yCurrentPos += 5;
  290.                 }
  291.                 if (yTruePos - yCurrentPos <= 50 && yTruePos - yCurrentPos > 40)
  292.                 {
  293.                     yCurrentPos += 6;
  294.                 }
  295.                 if (yTruePos - yCurrentPos <= 60 && yTruePos - yCurrentPos > 50)
  296.                 {
  297.                     yCurrentPos += 7;
  298.                 }
  299.                 if (yTruePos - yCurrentPos <= 70 && yTruePos - yCurrentPos > 60)
  300.                 {
  301.                     yCurrentPos += 8;
  302.                 }
  303.                 if (yTruePos - yCurrentPos <= 80 && yTruePos - yCurrentPos > 70)
  304.                 {
  305.                     yCurrentPos += 9;
  306.                 }
  307.                 if (yTruePos - yCurrentPos <= 90 && yTruePos - yCurrentPos > 80)
  308.                 {
  309.                     yCurrentPos += 10;
  310.                 }
  311.                 if (yTruePos - yCurrentPos <= 100 && yTruePos - yCurrentPos > 90)
  312.                 {
  313.                     yCurrentPos += 11;
  314.                 }
  315.                 if (yTruePos - yCurrentPos <= 110 && yTruePos - yCurrentPos > 100)
  316.                 {
  317.                     yCurrentPos += 12;
  318.                 }
  319.                 if (yTruePos - yCurrentPos <= 120 && yTruePos - yCurrentPos > 110)
  320.                 {
  321.                     yCurrentPos += 13;
  322.                 }
  323.                 if (yTruePos - yCurrentPos <= 130 && yTruePos - yCurrentPos > 120)
  324.                 {
  325.                     yCurrentPos += 14;
  326.                 }
  327.                 if (yTruePos - yCurrentPos <= 140 && yTruePos - yCurrentPos > 130)
  328.                 {
  329.                     yCurrentPos += 15;
  330.                 }
  331.                 if (yTruePos - yCurrentPos <= 150 && yTruePos - yCurrentPos > 140)
  332.                 {
  333.                     yCurrentPos += 16;
  334.                 }
  335.                 if (yTruePos - yCurrentPos <= 160 && yTruePos - yCurrentPos > 150)
  336.                 {
  337.                     yCurrentPos += 17;
  338.                 }
  339.                 if (yTruePos - yCurrentPos <= 170 && yTruePos - yCurrentPos > 160)
  340.                 {
  341.                     yCurrentPos += 18;
  342.                 }
  343.                 if (yTruePos - yCurrentPos <= 180 && yTruePos - yCurrentPos > 170)
  344.                 {
  345.                     yCurrentPos += 19;
  346.                 }
  347.                 if (yTruePos - yCurrentPos <= 190 && yTruePos - yCurrentPos > 180)
  348.                 {
  349.                     yCurrentPos += 20;
  350.                 }
  351.                 if (yTruePos - yCurrentPos > 190)
  352.                 {
  353.                     yCurrentPos += 21;
  354.                 }
  355.             }
  356.             if (yCurrentPos > yTruePos)
  357.             {
  358.                 if (yCurrentPos - yTruePos <= 5)
  359.                 {
  360.                     yCurrentPos -= 1;
  361.                 }
  362.                 if (yCurrentPos - yTruePos <= 10 && yCurrentPos - yTruePos > 5)
  363.                 {
  364.                     yCurrentPos -= 2;
  365.                 }
  366.                 if (yCurrentPos - yTruePos <= 20 && yCurrentPos - yTruePos > 10)
  367.                 {
  368.                     yCurrentPos -= 3;
  369.                 }
  370.                 if (yCurrentPos - yTruePos <= 30 && yCurrentPos - yTruePos > 20)
  371.                 {
  372.                     yCurrentPos -= 4;
  373.                 }
  374.                 if (yCurrentPos - yTruePos <= 40 && yCurrentPos - yTruePos > 30)
  375.                 {
  376.                     yCurrentPos -= 5;
  377.                 }
  378.                 if (yCurrentPos - yTruePos <= 50 && yCurrentPos - yTruePos > 40)
  379.                 {
  380.                     yCurrentPos -= 6;
  381.                 }
  382.                 if (yCurrentPos - yTruePos <= 60 && yCurrentPos - yTruePos > 50)
  383.                 {
  384.                     yCurrentPos -= 7;
  385.                 }
  386.                 if (yCurrentPos - yTruePos <= 70 && yCurrentPos - yTruePos > 60)
  387.                 {
  388.                     yCurrentPos -= 8;
  389.                 }
  390.                 if (yCurrentPos - yTruePos <= 80 && yCurrentPos - yTruePos > 70)
  391.                 {
  392.                     yCurrentPos -= 9;
  393.                 }
  394.                 if (yCurrentPos - yTruePos <= 90 && yCurrentPos - yTruePos > 80)
  395.                 {
  396.                     yCurrentPos -= 10;
  397.                 }
  398.                 if (yCurrentPos - yTruePos <= 100 && yCurrentPos - yTruePos > 90)
  399.                 {
  400.                     yCurrentPos -= 11;
  401.                 }
  402.                 if (yCurrentPos - yTruePos <= 110 && yCurrentPos - yTruePos > 100)
  403.                 {
  404.                     yCurrentPos -= 12;
  405.                 }
  406.                 if (yCurrentPos - yTruePos <= 120 && yCurrentPos - yTruePos > 110)
  407.                 {
  408.                     yCurrentPos -= 13;
  409.                 }
  410.                 if (yCurrentPos - yTruePos <= 130 && yCurrentPos - yTruePos > 120)
  411.                 {
  412.                     yCurrentPos -= 14;
  413.                 }
  414.                 if (yCurrentPos - yTruePos <= 140 && yCurrentPos - yTruePos > 130)
  415.                 {
  416.                     yCurrentPos -= 15;
  417.                 }
  418.                 if (yCurrentPos - yTruePos <= 150 && yCurrentPos - yTruePos > 140)
  419.                 {
  420.                     yCurrentPos -= 16;
  421.                 }
  422.                 if (yCurrentPos - yTruePos <= 160 && yCurrentPos - yTruePos > 150)
  423.                 {
  424.                     yCurrentPos -= 17;
  425.                 }
  426.                 if (yCurrentPos - yTruePos <= 170 && yCurrentPos - yTruePos > 160)
  427.                 {
  428.                     yCurrentPos -= 18;
  429.                 }
  430.                 if (yCurrentPos - yTruePos <= 180 && yCurrentPos - yTruePos > 170)
  431.                 {
  432.                     yCurrentPos -= 19;
  433.                 }
  434.                 if (yCurrentPos - yTruePos <= 190 && yCurrentPos - yTruePos > 180)
  435.                 {
  436.                     yCurrentPos -= 20;
  437.                 }
  438.                 if (yCurrentPos - yTruePos > 190)
  439.                 {
  440.                     yCurrentPos -= 21;
  441.                 }
  442.             }
  443.             #endregion
  444.         }
  445.         #endregion
  446.     }
  447. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement