private void HandleBridgeCheating() // NOTE: Only rubberbanding on bridge...Why? { if (dinos == null || dinos.Length == 0) { dinos = dinoTracking.GetDinoArray(); } if (dinos.Length != 0 && !hasValidDinoArray) { if (dinos[0] != null) { dinoArrayPositions = new List <int>(); for (int i = 0; i < dinos.Length; i++) { if (dinos[i] == gameObject) { aiArrayPosition = i; } else if (dinos[i].tag == "Dino") { dinoArrayPositions.Add(i); } } hasValidDinoArray = true; } } if (hasValidDinoArray) { int[] positions = dinoTracking.GetCurrentPositions(); int lastPlayerPosition = -1; //Find position of last human player foreach (int dino in dinoArrayPositions) { if (lastPlayerPosition < positions[dino]) { lastPlayerPosition = positions[dino]; } } int myPosition = positions[aiArrayPosition]; if (lastPlayerPosition < myPosition) //Player is beating me { if (!isCheating) { TurnOnCheating(); } } else //Player is losing to me { if (isCheating) { TurnOffCheating(); } } } }
private void SwitchPositions(int playerLocation, int opponentPosition) { GameObject[] dinos = dinoTracking.GetDinoArray(); Vector3 playerTempPosition = dinos[playerLocation].transform.position; Quaternion playerTempRotation = dinos[playerLocation].transform.rotation; dinos[playerLocation].transform.position = dinos[opponentPosition].transform.position; dinos[playerLocation].transform.rotation = dinos[opponentPosition].transform.rotation; dinos[opponentPosition].transform.position = playerTempPosition; dinos[opponentPosition].transform.rotation = playerTempRotation; dinos[opponentPosition].GetComponent <DinosaurHealth>().Damage(damage); StartCoroutine(effect()); }
// Use this for initialization IEnumerator OnLevelWasLoaded() { //create the hud group grpObj = new GameObject("HUD Group"); gameFont = (Font)Resources.Load("GUI/Materials/Coalition_v2"); buttonFont = (Font)Resources.Load("GUI/Materials/Typodermic - EthnocentricRg-Italic"); grpObj.layer = 5; /* test = new GameObject[4]; * test[0] = new GameObject("test object"); * test[1] = new GameObject("test object"); * test[2] = new GameObject("test object"); * test[3] = new GameObject("test object");*/ //settings for the mini map /*if(Application.loadedLevelName == "DumbellTrack") * mapInfo = new MapGUIInfo(105.0f, new Rect(89.5f, 24.7f, 1, 1), new Rect(85, 10, 10, 30), (Texture)Resources.Load("GUI/Materials/DumbBellmap")); * else * mapInfo = new MapGUIInfo();*/ //getting the menu script menu = GameObject.FindGameObjectWithTag("Menu"); menuScript = menu.GetComponent <MenuControl>(); netView = GetComponent <NetworkView>(); networkHandlerObject = GameObject.FindGameObjectWithTag("NetworkHandler"); networkHandler = networkHandlerObject.GetComponent("NetworkGameHandler") as NetworkGameHandler; //AddItem = ItemToAdd; xMulti = Screen.width / 100.0f; yMulti = Screen.height / 100.0f; //textures for the hub hudGfx = new Texture[4]; /*hudGfx[0] = (Texture)Resources.Load("GUI/Materials/Hub1st"); * hudGfx[1] = (Texture)Resources.Load("GUI/Materials/Hub2nd"); * hudGfx[2] = (Texture)Resources.Load("GUI/Materials/Hub3rd"); * hudGfx[3] = (Texture)Resources.Load("GUI/Materials/Hub4th"); * hudGfx[4] = (Texture)Resources.Load("GUI/Materials/lapGraphic"); * hudGfx[5] = (Texture)Resources.Load("GUI/Materials/slashGraphic");*/ hudGfx[0] = (Texture)Resources.Load("GUI/Materials/HudHealthBar"); hudGfx[1] = (Texture)Resources.Load("GUI/Materials/HudBorder"); hudGfx[2] = (Texture)Resources.Load("GUI/Materials/HudLeftTrigger"); hudGfx[3] = (Texture)Resources.Load("GUI/Materials/HudRightTrigger"); progressGfx = new Texture[11]; progressGfx[0] = (Texture)Resources.Load("GUI/Materials/HudProgressionBar"); progressGfx[1] = (Texture)Resources.Load("GUI/Materials/HudDilophSmall"); progressGfx[2] = (Texture)Resources.Load("GUI/Materials/HudHespSmall"); progressGfx[3] = (Texture)Resources.Load("GUI/Materials/HudSpinoSmall"); progressGfx[4] = (Texture)Resources.Load("GUI/Materials/HudTRexSmall"); progressGfx[5] = (Texture)Resources.Load("GUI/Materials/HudTroodonSmall"); progressGfx[6] = (Texture)Resources.Load("GUI/Materials/HudDilophBig"); progressGfx[7] = (Texture)Resources.Load("GUI/Materials/HudHespBig"); progressGfx[8] = (Texture)Resources.Load("GUI/Materials/HudSpinoBig"); progressGfx[9] = (Texture)Resources.Load("GUI/Materials/HudTRexBig"); progressGfx[10] = (Texture)Resources.Load("GUI/Materials/HudTroodonBig"); //textures for the numbers /*numGfx = new Texture[10]; * numGfx[0] = (Texture)Resources.Load("GUI/Materials/num0Graphic"); * numGfx[1] = (Texture)Resources.Load("GUI/Materials/num1Graphic"); * numGfx[2] = (Texture)Resources.Load("GUI/Materials/num2Graphic"); * numGfx[3] = (Texture)Resources.Load("GUI/Materials/num3Graphic"); * numGfx[4] = (Texture)Resources.Load("GUI/Materials/num4Graphic"); * numGfx[5] = (Texture)Resources.Load("GUI/Materials/num5Graphic"); * numGfx[6] = (Texture)Resources.Load("GUI/Materials/num6Graphic"); * numGfx[7] = (Texture)Resources.Load("GUI/Materials/num7Graphic"); * numGfx[8] = (Texture)Resources.Load("GUI/Materials/num8Graphic"); * numGfx[9] = (Texture)Resources.Load("GUI/Materials/num9Graphic");*/ //textures for the health bar healthBarGfx = (Texture)Resources.Load("GUI/Materials/HudHealthBar"); //healthBarRedGfx = (Texture)Resources.Load("GUI/Materials/EnemyHealthBarRed"); //healthCoverGfx = (Texture)Resources.Load("GUI/Materials/HudOtherHealthBoarder"); //texture for the health border healthBorderGfx = (Texture)Resources.Load("GUI/Materials/HudOtherHealthBoarder"); //texture for weapon graphics itemsGfx = new Texture[3]; itemsGfx[0] = (Texture)Resources.Load("GUI/Materials/HudMelee"); itemsGfx[1] = (Texture)Resources.Load("GUI/Materials/HudHealth"); itemsGfx[2] = (Texture)Resources.Load("GUI/Materials/HudTurbo"); //textures for the points on the mini map mapPosGfx = (Texture)Resources.Load("GUI/Materials/MapPointPosition"); //texture for the finish object finishGfx = (Texture)Resources.Load("GUI/Materials/HudFinish"); finishPlaceGfx = new Texture[4]; finishPlaceGfx[0] = (Texture)Resources.Load("GUI/Materials/Hud1st"); finishPlaceGfx[1] = (Texture)Resources.Load("GUI/Materials/Hud2nd"); finishPlaceGfx[2] = (Texture)Resources.Load("GUI/Materials/Hud3rd"); finishPlaceGfx[3] = (Texture)Resources.Load("GUI/Materials/Hud4th"); dinoIconsGfx = new Texture[1]; dinoIconsGfx[0] = (Texture)Resources.Load("GUI/Materials/HubIconDino"); pauseMenuGfx = new Texture[5]; pauseMenuGfx[0] = (Texture)Resources.Load("GUI/Materials/PauseMenuBackground"); pauseMenuGfx[1] = (Texture)Resources.Load("GUI/Materials/EmptyButtonSmall"); /*pauseMenuGfx[2] = (Texture)Resources.Load("GUI/Materials/PauseRestart"); * pauseMenuGfx[3] = (Texture)Resources.Load("GUI/Materials/PauseSettings"); * pauseMenuGfx[4] = (Texture)Resources.Load("GUI/Materials/QuitButton")*/; healthDangerGfx = (Texture)Resources.Load("GUI/Materials/Dying"); //************************************************************************ //positionObjs = CreateGUITxtr("Current Position", hudGfx[0], new Vector3(0, 0, 0)); //create guitextures for the lap info /*lapObjs = new GameObject[4]; * lapObjs[0] = CreateGUIText("Lap", "Lap", new Vector3(0, 0, 0)); * lapObjs[1] = CreateGUIText("Current Lap", "0", new Vector3(0, 0, 0)); * lapObjs[2] = CreateGUIText("Slash", "/", new Vector3(0, 0, 0)); * lapObjs[3] = CreateGUIText("Max Lap", "0", new Vector3(0, 0, 0));*/ /*lapObjs[0].guiText.color = Color.cyan; * lapObjs[1].guiText.color = Color.cyan; * lapObjs[2].guiText.color = Color.cyan; * lapObjs[3].guiText.color = Color.cyan;*/ //create guitextures for the health bars healthBarObjs = new GameObject[4]; healthBarObjs[0] = CreateGUITxtr("Health Bar p1", healthBarGfx, new Vector3(0, 0, -6)); healthBarObjs[1] = CreateGUITxtr("Health Bar p2", healthBarGfx, new Vector3(0, 0, -6)); healthBarObjs[2] = CreateGUITxtr("Health Bar p3", healthBarGfx, new Vector3(0, 0, -6)); healthBarObjs[3] = CreateGUITxtr("Health Bar p4", healthBarGfx, new Vector3(0, 0, -6)); //create guitextures for the health borders healthBackgroundObjs = new GameObject[4]; healthBackgroundObjs[0] = CreateGUITxtr("Health Border p1", healthBorderGfx, new Vector3(0, 0, -5)); healthBackgroundObjs[1] = CreateGUITxtr("Health Border p2", healthBorderGfx, new Vector3(0, 0, -5)); healthBackgroundObjs[2] = CreateGUITxtr("Health Border p3", healthBorderGfx, new Vector3(0, 0, -5)); healthBackgroundObjs[3] = CreateGUITxtr("Health Border p4", healthBorderGfx, new Vector3(0, 0, -5)); //create guitextures for the player names playerNamesObjs = new GameObject[4]; playerNamesObjs[0] = CreateGUIText("Player 1 Name", "None", new Vector3(0, 0, -4)); playerNamesObjs[1] = CreateGUIText("Player 2 Name", "None", new Vector3(0, 0, -4)); playerNamesObjs[2] = CreateGUIText("Player 3 Name", "None", new Vector3(0, 0, -4)); playerNamesObjs[3] = CreateGUIText("Player 4 Name", "None", new Vector3(0, 0, -4)); playerNames = new string[4]; SetNames(); for (int i = 0; i < healthBarObjs.Length; i++) { healthBarObjs[i].layer = 0; healthBackgroundObjs[i].layer = 0; playerNamesObjs[i].layer = 0; healthBackgroundObjs[i].SetActive(false); healthBarObjs[i].SetActive(false); playerNamesObjs[i].SetActive(false); } /*mapObj = CreateGUITxtr("Map", mapInfo.MapTxtr, new Vector3(0, 0, 0)); * mapPosObjs = new GameObject[4]; * mapPosObjs[0] = CreateGUITxtr("Position Dot p1", mapPosGfx, new Vector3(0, 0, 0.5f)); * mapPosObjs[1] = CreateGUITxtr("Position Dot p2", mapPosGfx, new Vector3(0, 0, 0.5f)); * mapPosObjs[2] = CreateGUITxtr("Position Dot p3", mapPosGfx, new Vector3(0, 0, 0.5f)); * mapPosObjs[3] = CreateGUITxtr("Position Dot p4", mapPosGfx, new Vector3(0, 0, 0.5f));*/ finishObj = CreateGUITxtr("Finish", finishGfx, new Vector3(0, 0, 2)); finishObj.guiTexture.pixelInset = ResizeRect(new Rect(150, 0, 100, 100)); finishPlaceObj = CreateGUITxtr("Finish Place", hudGfx[0], new Vector3(0, 0, 3)); finishPlaceObj.guiTexture.pixelInset = ResizeRect(new Rect(-80, 20, 30, 70)); healthDangerObj = CreateGUITxtr("Finish Place", healthDangerGfx, new Vector3(0, 0, 1)); healthDangerObj.SetActive(false); hasFinished = false; //dinoIcon = CreateGUITxtr("Dino Icon", dinoIconsGfx[0], new Vector3(0, 0, 0)); //healthPercent = CreateButtonText("Health Percent", "100%", new Vector3(0, 0, 0)); raceDinos = dinoTrackingScript.GetDinoArray(); lapPos = new Rect[4]; //healthGrp = (GameObject)Instantiate(Resources.Load("GUI/HealthMaskObj"), Camera.main.transform.position, Quaternion.identity); //healthGrp.transform.Rotate(new Vector3(0, 90, 0)); //healthGrp = new GameObject("HealthGroup"); pauseMenuObjs = new GameObject[9]; pauseMenuObjs[0] = CreateGUITxtr("Pause Menu Background", pauseMenuGfx[0], new Vector3(0, 0, 1)); pauseMenuObjs[1] = CreateGUITxtr("ContinueTxtr", pauseMenuGfx[1], new Vector3(0, 0, 2)); pauseMenuObjs[2] = CreateGUITxtr("RestartTxtr", pauseMenuGfx[1], new Vector3(0, 0, 2)); pauseMenuObjs[3] = CreateGUITxtr("SettingTxtr", pauseMenuGfx[1], new Vector3(0, 0, 2)); pauseMenuObjs[4] = CreateGUITxtr("QuitTxtr", pauseMenuGfx[1], new Vector3(0, 0, 2)); pauseMenuObjs[5] = CreateButtonText("ContinueText", "C o n t i n u e", new Vector3(0, 0, 3)); pauseMenuObjs[6] = CreateButtonText("RestartText", "R e s t a r t", new Vector3(0, 0, 3)); pauseMenuObjs[7] = CreateButtonText("SettingText", "S e t t i n g s", new Vector3(0, 0, 3)); pauseMenuObjs[8] = CreateButtonText("QuitText", "Q u i t", new Vector3(0, 0, 3)); foreach (GameObject _obj in pauseMenuObjs) { _obj.SetActive(false); } pauseMenuPos = new Rect[5]; pauseMenuTextPos = new Vector2[4]; items = new GameObject[4]; items[0] = CreateGUITxtr("Item1", itemsGfx[0], new Vector3(0, 0, -2)); items[1] = CreateGUITxtr("Item2", itemsGfx[0], new Vector3(0, 0, -2)); items[2] = CreateGUITxtr("Item3", itemsGfx[1], new Vector3(0, 0, -2)); items[3] = CreateGUITxtr("Item4", itemsGfx[2], new Vector3(0, 0, -2)); items[0].SetActive(false); items[1].SetActive(false); items[2].SetActive(false); items[3].SetActive(false); isFading = new bool[4]; isFading[0] = false; isFading[1] = false; isFading[2] = false; isFading[3] = false; /*foreach(Transform child in healthGrp.transform) * { * //Debug.Log("the mask " + healthGrp); * if(child.name == "HealthBar") * { * healthGrpBar = child.gameObject; * } * else if(child.name == "ItemIcon1") * { * items[0] = child.gameObject; * } * else if(child.name == "ItemIcon2") * { * items[1] = child.gameObject; * } * else if(child.name == "ItemIcon3") * { * items[2] = child.gameObject; * } * * * }*/ healthGrpPos = new Rect[6]; healthGrpBar = CreateGUITxtr("PlayerHealthBar", hudGfx[0], new Vector3(0, 0, -3)); healthGrpBorder = CreateGUITxtr("PlayerHealthBorder", hudGfx[1], new Vector3(0, 0, -2)); healthGrpLeftTrigger = CreateGUITxtr("LeftTrigger", hudGfx[2], new Vector3(0, 0, -1)); healthGrpRightTrigger = CreateGUITxtr("RightTrigger", hudGfx[3], new Vector3(0, 0, -1)); healthPercent = CreateGUIText("Health Percent", "100%", new Vector3(0, 0, -3)); positionObj = CreateGUIText("Current Position", "", new Vector3(0, 0, 0)); positionObj.guiText.anchor = TextAnchor.UpperRight; positionPlaceObj = CreateGUIText("Current Position Place", "", new Vector3(0, 0, 0)); positionPlaceObj.guiText.anchor = TextAnchor.UpperLeft; progressPos = new Rect[5]; progressObjs = new GameObject[5]; progressObjs[0] = CreateGUITxtr("ProgressionBar", progressGfx[0], new Vector3(0, 0, 0)); progressObjs[1] = CreateGUITxtr("ProgressionBar", progressGfx[1], new Vector3(0, 0, -1)); progressObjs[2] = CreateGUITxtr("ProgressionBar", progressGfx[1], new Vector3(0, 0, -1)); progressObjs[3] = CreateGUITxtr("ProgressionBar", progressGfx[1], new Vector3(0, 0, -1)); progressObjs[4] = CreateGUITxtr("ProgressionBar", progressGfx[1], new Vector3(0, 0, -1)); raceDinos = dinoTrackingScript.GetDinoArray(); while (true) { if (raceDinos[3] != null) { break; } raceDinos = dinoTrackingScript.GetDinoArray(); yield return(null); } for (int i = 1; i < progressObjs.Length; i++) { if (dinoTrackingScript.playerNum == i - 1) { string dinoName = raceDinos[i].name.Substring(0, raceDinos[i].name.IndexOf("(")); progressObjs[i].guiTexture.texture = (Texture)Resources.Load("GUI/Materials/Hud" + dinoName + "Big"); progressObjs[i].transform.position = new Vector3(0, 0, -2); } else { string dinoName = raceDinos[i].name.Substring(0, raceDinos[i].name.IndexOf("(")); progressObjs[i].guiTexture.texture = (Texture)Resources.Load("GUI/Materials/Hud" + dinoName + "small"); } } //healthCover = CreateGUITxtr("Health Cover", healthCoverGfx, new Vector3(0, 0, 3)); //healthGrpBarRotation = healthGrpBar.transform.localEulerAngles; }