// Start is called before the first frame update void Start() { enemies = GetComponentsInChildren <Enemy>(); tresure = GetComponentInChildren <Tresure>(); tresure.gameObject.SetActive(false); enemyCount = enemies.Length; //Debug.Log(enemyCount); }
private void setTresureTile(int x, int y, Tresure tresure) { tresureInstance ins = new tresureInstance(tresure); for (int i = 0; i < tresure.h * tresure.w; i++) { tresureMap[i / tresure.w + y, i % tresure.w + x].wallSprite = tresure.Slice()[i]; tresureMap[i / tresure.w + y, i % tresure.w + x].instance = ins; tresureMap[i / tresure.w + y, i % tresure.w + x].tresureID = tresure.ID; ins.cellList.Add(tresureMap[i / tresure.w + y, i % tresure.w + x]); } }
// Start is called before the first frame update void Start() { StageNo = 0; //Instantiate(ObjField, new Vector3(0,0,0), Quaternion.identity); Theif = new PlayerBase(); Police1 = new PlayerBase(); Police2 = new PlayerBase(); // 宝物 TresureTotalNum = 0; Tresures = new Tresure[TresureNumMax]; TresureObjects = new GameObject[TresureNumMax]; for (int i = 0; i < TresureNumMax; ++i) { TresureNeedsData = new int[3] { 1, 3, 3 } } ; TresureNeed = TresureNeedsData[StageNo]; TresureGotNum = 0; for (int i = 0; i < TresureNumMax; ++i) { Tresures[i] = new Tresure(); Tresures[i].SetX(-1); Tresures[i].SetZ(-1); Tresures[i].SetAlive(false); Tresures[i].SetType(0); } GameTimer = 0.0f; InputGameTimer = 0.0f; GameInputCounter = 0; TileMax = ObjField.GetComponent <field>().TileMax; TileLength = ObjField.GetComponent <field>().TileLength; StageTileMax = ObjField.GetComponent <field>().StageTileMax; StageTileNumMax = StageTileMax[StageNo]; StageData = ObjField.GetComponent <field>().StageData; TotalTileLength = TileLength * StageTileNumMax; Vector3 posTheif = new Vector3(3, 0, 0); Vector3 posPolice1 = new Vector3(2, 0, 0); Vector3 posPolice2 = new Vector3(1, 0, 0); // プレイヤーと宝物並べる for (int i = 0; i < TileMax; ++i) { for (int j = 0; j < TileMax; ++j) { int data = StageData[StageNo, i, j]; if (data == 1) { posTheif = new Vector3(j * TileLength - TotalTileLength / 2.0f, 0.0f, i * (-1.0f) * TileLength + TotalTileLength / 2.0f); Theif.SetX(i); Theif.SetZ(j); Theif.SetVisible(true); Theif.SetOldX(-1); Theif.SetOldZ(-1); } else if (data == 2) { posPolice1 = new Vector3(j * TileLength - TotalTileLength / 2.0f, 0.0f, i * (-1.0f) * TileLength + TotalTileLength / 2.0f); Police1.SetX(i); Police1.SetZ(j); } else if (data == 3) { posPolice2 = new Vector3(j * TileLength - TotalTileLength / 2.0f, 0.0f, i * (-1.0f) * TileLength + TotalTileLength / 2.0f); Police2.SetX(i); Police2.SetZ(j); } else if (data == 7 || data == 8 || data == 9) { Tresures[TresureTotalNum].SetX(i); Tresures[TresureTotalNum].SetZ(j); Tresures[TresureTotalNum].SetAlive(true); Tresures[TresureTotalNum].SetType(data); GameObject obj = null; switch (data) { case 7: obj = ObjTresureA; break; case 8: obj = ObjTresureB; break; case 9: obj = ObjTresureC; break; default: obj = null; break; } TresureObjects[TresureTotalNum] = Instantiate(obj, new Vector3(j * TileLength - TotalTileLength / 2.0f, 1.0f, i * (-1.0f) * TileLength + TotalTileLength / 2.0f), Quaternion.identity); ++TresureTotalNum; } } } GameObjTheif = Instantiate(ObjTheif, posTheif, Quaternion.identity); GameObjTheif.transform.Rotate(new Vector3(0, 90, 0)); GameObjPolice1 = Instantiate(ObjPolice1, posPolice1, Quaternion.identity); GameObjPolice1.transform.Rotate(new Vector3(0, 90, 0)); GameObjPolice2 = Instantiate(ObjPolice2, posPolice2, Quaternion.identity); GameObjPolice2.transform.Rotate(new Vector3(0, 90, 0)); } bool thief_can_move = true; bool police1_can_move = true; bool police2_can_move = true; // Update is called once per frame void Update() { // count timer float preInputTimer = InputGameTimer; GameTimer += Time.deltaTime; InputGameTimer += Time.deltaTime; // input counter if (InputGameTimer > InputSpan) { InputGameTimer -= InputSpan; GameInputCounter++; // 移動できた? if (Theif.GetX() == Theif.GetOldX() && Theif.GetZ() == Theif.GetOldZ() ) { Theif.SetVisible(true); } else { Theif.SetVisible(false); } // ライトの上? if (isLightBlock(Theif.GetX(), Theif.GetZ())) { Theif.SetVisible(true); } Theif.SetOldX(Theif.GetX()); Theif.SetOldZ(Theif.GetZ()); //isMoveTurn = false; } if (1.5f < InputGameTimer && InputGameTimer < 2f) { // move if (thief_can_move) { var tmp = MoveTheif(); if (tmp) { thief_can_move = false; } } if (police1_can_move) { var tmp = MovePolice1(); if (tmp) { police1_can_move = false; } } if (police2_can_move) { var tmp = MovePolice2(); if (tmp) { police2_can_move = false; } } } if (0.8f < InputGameTimer && InputGameTimer < 1.2f) { thief_can_move = true; police1_can_move = true; police2_can_move = true; } // 宝物実行 ExecTresure(); // 捕まえた実行 ExecCapture(); // 泥棒表示 DrawTheif(); // 警察表示 DrawPolice1(); DrawPolice2(); }
public tresureInstance(Tresure t) { data = t; cellList = new List <cell>(); }