void Awake() { shipsGrid = transform.parent.GetComponent <ShipsGrid>(); gridCollider = shipsGrid.gameObject.GetComponent <Collider>(); playerCamera = GameObject.Find("MainCamera").GetComponent <Camera>(); ownCollider = GetComponent <BoxCollider>(); ownCollider.size = new Vector3(deckAmount + 2, 2, 3); ownCollider.center = new Vector3(((float)deckAmount - 1) / 2, 0, 0); deckPrefab = Resources.Load("Deck") as GameObject; decksList = new List <Transform>(); for (int i = 0; i < deckAmount; i++) { GameObject deck = Instantiate(deckPrefab, transform, false); deck.transform.localPosition = new Vector3((float)i, 0f, 0f); decksList.Add(deck.transform); } whenStatic = Resources.Load("Material/Static", typeof(Material)) as Material; whenDragging = Resources.Load("Material/Transparent", typeof(Material)) as Material; whenIntersects = Resources.Load("Material/Red", typeof(Material)) as Material; }
public void Start() // AI difficulty => ship placement + tactic { ShipsGrid aiGrid = opponentGrid.GetComponent <ShipsGrid>(); int difficulty = Difficulty.difficultyValue; int medium = Random.Range(0, 2); int hard = Random.Range(0, 3); if (difficulty == 0) { aiTactic = (Tactic)0; aiGrid.AutoPlacement_Random(); } else if (difficulty == 1) { aiTactic = (Tactic)1; // DEBUG //aiTactic = (Tactic)Random.Range(0, 2); if (medium == 0) { aiGrid.AutoPlacement_AntiDiagonal(); } else { aiGrid.AutoPlacement_Coasts(); } } else { aiTactic = (Tactic)2; // DEBUG //aiTactic = (Tactic)Random.Range(1, 3); if (hard == 0) { aiGrid.AutoPlacement_Random(); } else if (hard == 1) { aiGrid.AutoPlacement_AntiDiagonal(); } else { aiGrid.AutoPlacement_Coasts(); } } opponentTerrain.gameObject.SetActive(false); foreach (Transform child in opponentGrid.transform) { child.gameObject.SetActive(false); } }
public void GetMyShipsGrid() { if (SceneManager.GetActiveScene().name != "Game_PVP") { return; } OnlineGameManager ogm = gameObject.GetComponent <OnlineGameManager>(); if (ogm.OwnGamePlayerSide() == OnlineGameManager.Side.Left) { shipsGrid = GameObject.Find("Grid_01").GetComponent <ShipsGrid>(); } else if (ogm.OwnGamePlayerSide() == OnlineGameManager.Side.Right) { shipsGrid = GameObject.Find("Grid_02").GetComponent <ShipsGrid>(); } }