void Start() { parent = transform.parent.gameObject.GetComponent<ShipScript>(); system = GameObject.FindGameObjectWithTag("System"); rpcScript = system.GetComponent<RPCScript>(); if (this.name == "Bow") gameObject.renderer.material.color = Color.black; if (this.name == "Stern") gameObject.renderer.material.color = Color.white; if (parent.player != parent.gameScript.myname) { Debug.Log ("parent name " + parent.player + " gamescript name " + parent.gameScript.myname); Debug.Log ("not my ship so disable renderer"); gameObject.renderer.enabled = false; Debug.Log ("Disabling visibility on cell"); parent.GetCellForSection(this.gameObject).SetVisible(false); } }
/** GAMELOOP METHODS **/ // Use this for initialization public void Init() { gameObject.renderer.material.color = Color.blue; available = true; system = GameObject.FindGameObjectWithTag("System"); gridScript = system.GetComponent<GridScript>(); gameScript = system.GetComponent<GameScript>(); rpcScript = system.GetComponent<RPCScript>(); instanceID = gameObject.GetInstanceID(); }
// Use this for initialization void Start() { gridScript = gameObject.GetComponent<GridScript>(); rpcScript = gameObject.GetComponent<RPCScript>(); // Initialize game state variables curPlayAction = PlayAction.None; curGameState = GameState.Connecting; // Run game initialization gridInited = false; existSelection = false; string playerName = PlayerPrefs.GetString("playerName"); myname = playerName; rpcScript.sendPlayerName(myname); setPlayerType(); int LoadedInt = PlayerPrefs.GetInt("LoadedGame"); if (LoadedInt == 1) { //This is a loaded game //isLoadedGame = true; //Send RPC to say its a loaded game. //Change current game state. isLoadedGame = true; loadFilePath = PlayerPrefs.GetString("LoadedGamePath"); Debug.Log(loadFilePath); } player1SetupDone = false; player2SetupDone = false; player1SetupAcceptance = false; player2SetupAcceptance = false; setupAccepted = false; myRadarCount = 1; myKamikazeCount = 1; myCruiserCount = 2; myDestroyerCount = 3; myTorpedoCount = 2; myMineLayerCount = 2; }
/** GAMELOOP METHODS **/ // Use this for initialization public void Init() { system = GameObject.FindGameObjectWithTag("System"); gameScript = system.GetComponent<GameScript>(); gridScript = system.GetComponent<GridScript>(); rpcScript = system.GetComponent<RPCScript>(); baseSections = new List<GameObject>(); health = new int[10]; GameObject[] tBaseSection = new GameObject[10]; for (int i = 0; i < 10; i++) { health [i] = 1; } foreach (Transform child in transform) { string[] section = child.name.Split('_'); if (section[0] == "BaseSection") { int index = int.Parse(section[1]); Debug.Log(child.name + " : " + index); tBaseSection[index] = child.gameObject; } } baseSections = new List<GameObject>(tBaseSection); }
void Start() { parent = transform.parent.gameObject.GetComponent<BaseScript>(); system = GameObject.FindGameObjectWithTag("System"); rpcScript = system.GetComponent<RPCScript>(); }
// Use this for initialization public void Init() { // Create grid of cells //rpcScript.shareReefSeed(reefSeed); /*For testing CellScript[,] testCells = range (3, 4, 5, 2); for (int x = 0; x < 5; x ++) { for (int y = 0; y < 2; y++) { testCells[x, y].selected = true; } }*/ // Initialize references to system and current selection currentSelection = new List<CellScript>(); reefCells = new List<CellScript>();; refreshCounter = 0; system = GameObject.FindGameObjectWithTag("System"); gameScript = system.GetComponent<GameScript>(); rpcScript = system.GetComponent<RPCScript>(); CreateGrid (); idSeedStack = new Stack(); // CRUDE WAY OF MAKING ID. CHANGE LATER for (int i=0; i<50;i++) { idSeedStack.Push(i); } }
// Use this for initialization public void Init() { system = GameObject.FindGameObjectWithTag("System"); gameScript = system.GetComponent<GameScript>(); gridScript = system.GetComponent<GridScript>(); rpcScript = system.GetComponent<RPCScript>(); // Change the size for each sub ship speed = maxSpeed; health = new int[shipSize]; InitArmor (); // Retrieve prefabs from resources explosion = Resources.Load("explosion") as GameObject; waterSplash = Resources.Load("water_splash") as GameObject; // Add all child sections ship GameObject[] tShipSection = new GameObject[shipSize]; //Correct Order of ship instantiation. foreach (Transform child in transform) { //Debug.Log(child.name); //Debug.Log ("Size: " + shipSize + "and arrysize: " + tShipSection.Length); if (child.name == "Stern") tShipSection[0] = child.gameObject; if (child.name == "Bow") tShipSection[shipSize-1] = child.gameObject; string[] mid = child.name.Split('_'); if (mid[0] == "Mid") { int index = int.Parse(mid[1]); //Debug.Log(child.name + " : " + index); tShipSection[index] = child.gameObject; } } shipSections = new List<GameObject>(tShipSection); for (int i = 0; i < shipSize; i++) { Debug.Log(shipSections[i].transform.name + " for index: " + i); } // foreach (GameObject s in shipSections) { // Debug.Log(s.transform.name); // } //Debug.Log(shipSections[0].name + " : " + shipSections[1].name); }