public void ResetGameObject(Vector3 spawnLocation, ComputerLane computerLane) { if (isServer) { Vector3 rotation = team.GetTeamID() == TeamID.blue ? new Vector3(0,90,0) : new Vector3(0,270,0); RpcResetGameObject(spawnLocation,computerLane,rotation); RpcSetAnimatorActive(true); RpcSetAliveAnim(true); } }
public void ResetGameObject(Vector3 spawnPosition, ComputerLane computerLane) { if (isServer) { active = true; // Vector3 adjusted_spawnLocation = gameObject.GetComponent<GruntMovement>().AdjustToTerrain(spawnPosition); Vector3 rotation = team.GetTeamID() == TeamID.blue ? new Vector3(0,90,0) : new Vector3(0,270,0); RpcResetGameObject(spawnPosition, rotation, computerLane); } }
public void InitialiseDamageText(ComputerLane computerLane) { // when pool not initialised if (availableDamageTexts.Count == 0 && inUseDamageTexts.Count == 0){ InitialiseDamageTextPool(computerLane); }else{ ResetDamageTextPool(computerLane); } }
public void ResetGameObject(Vector3 spawnPosition, ComputerLane computerLane) { if (isServer) { active = true; gameObject.GetComponent<BaseHealth>().InitialiseBaseHealth(team, computerLane); gameObject.SetActive(active); gameObject.transform.position = spawnPosition; CmdSetActiveState(active, spawnPosition); } }
public void CreateLongPathGrid(Vector3 gridCentre, Vector2 gridSize, ComputerLane computerLane) { if (computerLane == ComputerLane.LEFT) leftGrid = new LongPathGrid(gridCentre, gridSize, nodeRadius, unwalkableLayer); else { rightGrid = new LongPathGrid(gridCentre, gridSize, nodeRadius, unwalkableLayer); foreach (Navigator navigator in navigators) navigator.InitialiseNavigator(rightGrid); } }
public void JoinScreen(string IPAddress, string portNumber, string numberOfScreensLeft, string numberOfScreensRight, string screenNumber, string string_lane) { SetIPAddress(IPAddress); SetPort(portNumber); SetScreen(screenNumber); SetNumberOfScreens(numberOfScreensLeft, true); SetNumberOfScreens(numberOfScreensRight, false); isServer = false; lane = string_lane.Equals("right", StringComparison.OrdinalIgnoreCase) ? ComputerLane.RIGHT : ComputerLane.LEFT; NetworkManager.singleton.StartClient(); }
public void InitialiseBaseHealth(Team team, ComputerLane computerLane) { this.team = team; GameObject[] bases = GameObject.FindGameObjectsWithTag(gameObject.tag); foreach (GameObject other in bases) { if(other && other != gameObject) { otherBase = other.GetComponent<BaseHealth>(); } } this.computerLane = computerLane; InitialiseHealth(computerLane); }
public virtual void InitialiseHealth(ComputerLane computerlane) { entityLocation = Camera.main.WorldToScreenPoint(gameObject.transform.position); if(isServer) { // if max heath isnt set, as can be set by later function currentHealth = maxHealth; percentOfHealth = currentHealth / maxHealth; healthBarLength = percentOfHealth * healthBarInitialLength; damageText = gameObject.GetComponent<DamageText>(); damageText.InitialiseDamageText(computerlane); } }
public void InitialiseDamageTextPool(ComputerLane computerLane) { availableDamageTexts = new LinkedList<GameObject>(); inUseDamageTexts = new LinkedList<GameObject>(); this.computerLane = computerLane; RpcSetComputerLane(computerLane); for(int i = 0; i < damageTextPoolSize; i++) { GameObject damageText = InitDamageText(); damageText.SetActive(false); availableDamageTexts.AddLast(damageText); } }
// Use this for initialization void Start() { currentLane = GraniteNetworkManager.lane; int screenNumber = GraniteNetworkManager.screeNumber; isServer = GraniteNetworkManager.isServer; Debug.Log("Screen Number: " + screenNumber); float width = 100; //the width of the screen in the game Vector3 v3 = currentLane == ComputerLane.LEFT ? initialPositionLeft : initialPositionRight; //get current pos v3.x = width / 2 + width*screenNumber; //offset the camera correctly transform.position = v3; print(transform.rotation.eulerAngles); transform.rotation = Quaternion.Euler(currentLane == ComputerLane.LEFT ? rotationLeft : rotationRight); }
public void RpcResetGameObject(Vector3 spawnPosition, Vector3 rotation, ComputerLane computerLane) { active = true; if(isServer) gameObject.GetComponent<Attack>().initiliseAttack(); gameObject.GetComponent<GruntMovement>().initialiseMovement(spawnPosition); gameObject.GetComponent<SynchronisedMovement>().ResetMovement(spawnPosition, rotation); if(isServer) gameObject.GetComponent<TargetSelect>().InitialiseTargetSelect(team.GetTeamID(), spawnPosition); //set Health to Max gameObject.GetComponent<Health>().InitialiseHealth(computerLane); gameObject.GetComponent<GruntClientPathFinder>().InitilizePathFindiding(spawnPosition); gameObject.SetActive(active); for(int i = 0; i < transform.childCount; i++){ if(transform.GetChild(i).name.Contains("DamageText")){ transform.GetChild(i).gameObject.SetActive(false); } } }
public void Initialise(ComputerLane computerlane, Team blueTeam, Team redTeam) { // set initial colours percentRed = 0f; percentBlue = 0f; towerState = TowerState.neutral; RpcSetTowerState(towerState); captureBarHeight = (Screen.height / 150) < 3? 3 : Screen.height / 150; captureBarHeight -= captureBarHeight % 3; captureBarHeight = 5 * captureBarHeight / 3; yOffset = captureBarOffset * captureBarHeight; entityLocation = Camera.main.WorldToScreenPoint(gameObject.transform.position); captureBarLength = (percentRed / 100) * captureBarInitialLength; this.computerLane = computerlane; this.blueTeam = blueTeam; this.redTeam = redTeam; }
// Update is called once per frame void LateUpdate() { if (isServer) { if (Input.GetKey(KeyCode.RightArrow)) { transform.Translate(new Vector3(speed * Time.deltaTime, 0, 0)); } if (Input.GetKey(KeyCode.LeftArrow)) { transform.Translate(new Vector3(-speed * Time.deltaTime, 0, 0)); } if(Input.GetKeyDown(KeyCode.V)){ //switch view to other lane transform.rotation = Quaternion.Euler(currentLane == ComputerLane.RIGHT ? rotationLeft : rotationRight); Vector3 v3 = transform.position; v3.z = currentLane == ComputerLane.RIGHT ? initialPositionLeft.z : initialPositionRight.z; transform.position = v3; currentLane = currentLane == ComputerLane.RIGHT ? ComputerLane.LEFT : ComputerLane.RIGHT; } } }
void GenerateComputerLane(int screenNumber, int numScreens, ComputerLane computerLane) { if (isServer) { GenerateTerrain(screenNumber, numScreens, computerLane); GenerateLongPathGridServer(numScreens,computerLane); } else { //Request scenry for the current screen and the neighbouring screens if possible List<int> screenNumbers = new List<int>(); if(screenNumber > 0) { GenerateTerrain(screenNumber-1, numScreens, computerLane); screenNumbers.Add(screenNumber-1); } GenerateTerrain(screenNumber, numScreens, computerLane); screenNumbers.Add(screenNumber); if(screenNumber + 1 < numScreens) { GenerateTerrain(screenNumber+1, numScreens, computerLane); screenNumbers.Add(screenNumber+1); } screensRequested = screenNumbers.Count; } }
public void SetComputerLane(ComputerLane computerLane) { RpcSetComputerLane(computerLane); }
private void setTextMeshDirection(ComputerLane computerLane) { transform.FindChild("HeroName").gameObject.GetComponent<NameHero>().setTextRotation(computerLane == ComputerLane.RIGHT ? new Vector3(0,0,0) : new Vector3(0,180,0)); }
public void CmdSetTextMeshDirection(ComputerLane computerLane) { RpcSetTextMeshDirection(computerLane); }
public void RpcResetGameObject(Vector3 spawnLocation, ComputerLane computerLane, Vector3 rotation) { active = true; gameObject.GetComponent<HeroMovement>().initialiseMovement(spawnLocation); if(isServer) gameObject.GetComponent<Attack>().initiliseAttack(); if(isServer){ // initialise targeting and movement targetSelect = GetComponent<TargetSelect>(); targetSelect.InitialiseTargetSelect (team.GetTeamID(), spawnLocation); } gameObject.GetComponent<SynchronisedMovement>().ResetMovement(spawnLocation, rotation); //set Health to Max gameObject.GetComponent<Health>().InitialiseHealth(computerLane); gameObject.SetActive(active); }
public void setComputerLane(ComputerLane computerLane) { this.computerLane = computerLane; gameObject.GetComponent<HeroMovement>().setComputerLane(computerLane); setTextMeshDirection(computerLane); CmdSetTextMeshDirection(computerLane); gameObject.GetComponent<DamageText>().SetComputerLane(computerLane); setHeroName(playerName); }
private Vector3 GetHeroSpawnLocation(ComputerLane computerLane) { Tower forwardTower = getForwardTower(computerLane); if (forwardTower == null){ return GetSpawnLocation(computerLane); }else{ float zPos = forwardTower.transform.position.z; float xPos = forwardTower.transform.position.x + (teamID == TeamID.blue ? 6 : -6); return new Vector3(xPos,0,zPos); } }
private Tower getForwardTower(ComputerLane computerLane) { Tower forwardTower = null; float distanceFromBase = 0; foreach (Tower tower in capturedTowers){ if (tower.computerLane == computerLane){ float distance = Mathf.Abs(tower.transform.position.x - (computerLane == ComputerLane.LEFT? basePositionLeft.x: basePositionRight.x)); if (distance > distanceFromBase){ distanceFromBase = distance; forwardTower = tower; } } } return forwardTower; }
public void PlayerSwitchLaneHandler(string playerID, ComputerLane computerLane) { Debug.Log ("[SocketIO] Player has switched lane"); JSONObject dataJSON = new JSONObject(JSONObject.Type.OBJECT); dataJSON.AddField("playerID", playerID); dataJSON.AddField("lane", (int)computerLane); socket.Emit ("gamePlayerSwitchLane", dataJSON); }
private Vector3 GetSpawnLocation(ComputerLane computerLane) { float xPos; Vector3 pos; int tries = 0; do { int randomNumber = Random.Range(0, numberOfChannels); float zPos = computerLane == ComputerLane.LEFT ? randomNumber * zPositionOffsetLeft + Teams.minZLeft + Teams.bottomOffsetLeft : randomNumber * zPositionOffsetRight + Teams.minZRight + Teams.bottomOffsetRight; if (teamID == TeamID.blue) xPos = (computerLane == ComputerLane.LEFT ? teamBaseLeft : teamBaseRight).transform.position.x + 10; else xPos = (computerLane == ComputerLane.LEFT ? teamBaseLeft : teamBaseRight).transform.position.x - 10; pos = new Vector3(xPos, 0, zPos); tries++; } while(tries <= maxTriesForSpawnPostion && !validSpawnPosition(pos)); pos.y = 0; return pos; }
public void setComputerLane(ComputerLane computerLane) { this.computerLane = computerLane; }
public static void PlayerHasJoined(string playerID, TeamID teamID, GameState.State state, float playerMaxHealth, float baseMaxHealth, Hero.HeroClass heroClass, int specialOne, int specialTwo, int specialThree, ComputerLane computerLane) { socketIOManager.PlayerJoinHandler (playerID, teamID, state, playerMaxHealth, baseMaxHealth, heroClass, specialOne, specialTwo, specialThree, computerLane); }
private void spawnGrunt(int i, ComputerLane computerLane) { GameObject grunt = getGrunt(); grunt.GetComponent<Grunt>().ResetGameObject(GetSpawnLocation(computerLane), computerLane); }
private void ResetDamageTextPool(ComputerLane computerLane) { this.computerLane = computerLane; RpcSetComputerLane(computerLane); // clear not used pool and set inactive lock (availableDamageTexts) { while(inUseDamageTexts.Count > 0){ GameObject damageTextObject = inUseDamageTexts.First.Value; damageTextObject.SetActive(false); inUseDamageTexts.RemoveFirst(); availableDamageTexts.AddLast(damageTextObject); } } }
private void RpcSetComputerLane(ComputerLane computerLane) { this.computerLane = computerLane; }
public static void PlayerSwitchLaneHandler(string playerID, ComputerLane computerLane) { socketIOManager.PlayerSwitchLaneHandler(playerID, computerLane); }
public void PlayerJoinHandler(string playerID, TeamID teamID, GameState.State state, float playerMaxHealth, float baseMaxHealth, Hero.HeroClass heroClass, int specialOne, int specialTwo, int specialThree, ComputerLane computerLane) { Debug.Log ("[SocketIO] Player has joined"); JSONObject dataJSON = new JSONObject(JSONObject.Type.OBJECT); dataJSON.AddField("ok", 1); dataJSON.AddField("playerID", playerID); dataJSON.AddField("teamID", (int)teamID); dataJSON.AddField ("state", (int)state); dataJSON.AddField ("playerMaxHealth", playerMaxHealth); dataJSON.AddField ("baseMaxHealth", baseMaxHealth); dataJSON.AddField ("heroClass", (int)heroClass); dataJSON.AddField ("specialOne", specialOne); dataJSON.AddField ("specialTwo", specialTwo); dataJSON.AddField ("specialThree", specialThree); dataJSON.AddField ("lane", (int)computerLane); socket.Emit ("gamePlayerJoined", dataJSON); }