void OnTriggerEnter2D(Collider2D coll) { Instantiate(explosionPrefab, transform.position, Quaternion.identity); //衝突オブジェクトのスクリプトにアクセス RockController c = coll.gameObject.GetComponent <RockController>(); collDebrisType = c.GetDebrisType(); collDebrisName = c.GetDebrisName(); collDebrisOwner = c.GetDebrisOwner(); collDebrisLaunchSite = c.GetDebrisLaunchSite(); Debug.Log("coll obj:" + collDebrisType); //衝突オブジェクトを記録 State.SetCollDebrisType(collDebrisType); State.SetCollDebrisName(collDebrisName); State.SetCollDebrisOwner(collDebrisOwner); State.SetCollDebrisLaunchSite(collDebrisLaunchSite); //衝突オブジェクトと自機を破壊 Destroy(coll.gameObject); Destroy(gameObject); //ゲームオーバーシーンに遷移 SceneManager.LoadScene("GameOver"); }
void Update() { if(Input.GetKeyDown(KeyCode.Space)) { if(rotationAxis==Vector3.right) rotationAxis = Vector3.forward; else rotationAxis = Vector3.right; } if(Input.GetMouseButtonDown(2)) { RaycastHit hit = Utils.GetScreenWorldPos(Input.mousePosition, layerMask); pointSphere.position = hit.point+zAdjust; try { centerSphere.position = hit.transform.position+zAdjust; } catch(System.NullReferenceException) { } RockController thisSelection = hit.transform.GetComponent<RockController>(); if(lastSelection!=null) lastSelection.enabled = false; lastSelection = thisSelection; if(lastSelection!=null) lastSelection.enabled = true; resetTime = Time.timeSinceLevelLoad + 0.5f; } if(resetTime<=Time.timeSinceLevelLoad) { ResetPoints(); } }
public bool Mine(RockController rock) { actionTimer = mineRockAnimationTime; InCombat = false; Lock(); Equipment.ShowPickAxe(); if (lastTrainedSkill != Skill.Mining) { lastTrainedSkill = Skill.Mining; playerAnimations.StartMining(); return(true); } playerAnimations.Mine(); LookAt(rock.transform); if (rock.Mine(this)) { AddExp(rock.Experience, Skill.Mining); var amount = rock.Resource * Mathf.FloorToInt(Stats.Mining.CurrentValue / 10f); Statistics.TotalOreCollected += (int)amount; AddResource(Resource.Mining, amount); } return(true); }
void OnTriggerEnter2D(Collider2D other) { //Debug.Log(other.tag); if (other.tag == "ground") { RockController rockController = other.GetComponent <RockController>(); if (rockController != null) { if (rockController.charge < rockController.maxCharge) { rockController.charge += 1; rockController.PlaySound("rockHit"); if (rockController.charge == rockController.maxCharge) { rockController.GetComponent <SpriteRenderer>().sprite = rockController.rockFireSprite; } } else if (!rockController.beginLaunch && myBody != null) { rockController.launchDirection = myBody.velocity; rockController.beginLaunch = true; rockController.PlaySound("rockLaunch"); } rockController.lastHit = Time.time; } Destroy(this.gameObject); //hit = true; //this.gameObject.SetActive(false); } }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Rock")) { RockController rc = other.GetComponent <RockController>(); if (isBullet) { rc.OnBulletDestroy(); Destroy(GO); } else { rc.OnLaserDestroy(); } } if (other.CompareTag("UFO")) { UFOController uc = other.GetComponent <UFOController>(); if (isBullet) { uc.OnBulletDestroy(); Destroy(GO); } else { uc.OnBulletDestroy(); } } }
void BombSelfDestruct() { if (timer <= 0f) { RockController.CanSelfDestruct(); Destroy(this.gameObject); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { RockController.BombPickup(); Destroy(this.gameObject); } }
// Use this for initialization void Start() { pathGenerator = new PathGenerator(); activeCows = new List <CreatureController>(); cowPool = new List <CreatureController>(); treePool = new List <ForestController> (); activeTrees = new List <ForestController>(); rockPool = new List <RockController>(); activeRocks = new List <RockController>(); for (var i = 0; i < 30; i++) { RockController rock = (RockController)Instantiate(rock1Prefab, new Vector3(-1000, 0, 0), Quaternion.identity); rockPool.Add(rock); } //Populate the pool of trees for (var i = 0; i < 10; i++) { ForestController forest = (ForestController)Instantiate(forestPrefab, new Vector3(-1000, 0, 0), Quaternion.identity); treePool.Add(forest); } points = pathGenerator.GeneratePath(new Vector2(0, 0)); //lets get the last cell Vector3 firstCell = points[0]; Vector3 lastCell = points[points.Count - 1]; int numCells = (int)System.Math.Ceiling((lastCell.x - firstCell.x) / 20f); //now mazeManager.CreateCells(new Vector3(50, 0, 0), numCells, 10, 20); List <Bounds> bounds = mazeManager.GetCellsNotIntersectedBy(points); //mazeManager.MarkCellsAsPath(bounds); //mazeManager.RenderCells(bounds); foreach (RockController rock in rockPool) { mazeManager.AddToCell(rock, bounds); } //add the start position CreateBarn(new Vector3(100, 0, 0)); }
public void DisableSuperSkill() { isUsingSuperFlight = false; isUsingSuperSpeed = false; isUsingSuperTime = false; // Remove the superskill trail TrailRenderer trailRenderer = gameObject.GetComponentInChildren <TrailRenderer>(); trailRenderer.enabled = false; // Reset gravity to its orignal value gameObject.GetComponent <Rigidbody2D>().gravityScale = oriGravityScale; PteraMover.DeactivateTimeFreeze(); CaveFlamePit.DeactivateTimeFreeze(); Fireball.DeactivateTimeFreeze(); DestroyByTime.DeactivateTimeFreeze(); LaserBeam.DeactivateTimeFreeze(); Saw.DeactivateTimeFreeze(); LaserTurret.DeactivateTimeFreeze(); Bat.DeactivateTimeFreeze(); SwingingBoulder[] sb = FindObjectsOfType <SwingingBoulder>(); sb[0].DeactivateTimeFreeze(); sb[1].DeactivateTimeFreeze(); sb[2].DeactivateTimeFreeze(); sb[3].DeactivateTimeFreeze(); sb[4].DeactivateTimeFreeze(); sb[5].DeactivateTimeFreeze(); sb[6].DeactivateTimeFreeze(); RockController.DeactivateTimeFreeze(); Turret.DeactivateTimeFreeze(); PlayerController[] players = FindObjectsOfType <PlayerController>(); foreach (PlayerController p in players) { p.timeFreezeActivated = false; p.GetComponent <Rigidbody2D>().isKinematic = false; p.anim.enabled = true; } GameObject[] FXs = GameObject.FindGameObjectsWithTag("FX"); foreach (GameObject fx in FXs) { fx.GetComponent <ParticleSystem>().Play(); } Arrow.DeactivateTimeFreeze(); Puma.DeactivateTimeFreeze(); Piranha.DeactivateTimeFreeze(); Cobra.DeactivateTimeFreeze(); Saw.DeactivateTimeFreeze(); Banana.DeactivateTimeFreeze(); BananaSpawn[] bs = FindObjectsOfType <BananaSpawn>(); bs[0].DeactivateTimeFreeze(); bs[1].DeactivateTimeFreeze(); bs[2].DeactivateTimeFreeze(); }
void GenRock() { this.position = Random.value * 60.0f; if (this.position < 10.0f)//左から出現 { this.pos_x = -10.0f; this.pos_y = this.position; } else if (position < 30.0f)//上から出現 { this.pos_x = this.position - 10.0f; this.pos_y = 5.0f; } else if (position < 40.0f)//右から出現 { this.pos_x = 10.0f; this.pos_y = this.position - 30.0f; } else//下から出現 { this.pos_x = this.position - 40.0f; this.pos_y = -6.0f; } Debris_ID = Mathf.FloorToInt(Random.value * debrisLength); Debris_type = debrises.DEBRIS[this.Debris_ID].OBJECT_TYPE; if (Debris_type == "PAYLOAD") { Prefab = payloadPrefab; } else if (Debris_type == "DEBRIS") { Prefab = rockPrefab; } else if (Debris_type == "ROCKET BODY") { Prefab = rocketPrefab; } GameObject controller = Instantiate(Prefab, new Vector3(pos_x, pos_y, 0), Quaternion.identity); //RockControllerインスタンス作る スクリプトにアクセス RockController c = controller.GetComponent <RockController>(); c.SetDebrisType(Debris_type); c.SetDebrisName(Debris_name); c.SetDebrisOwner(Debris_owner); c.SetDebrisLanchSite(Debris_launch_site); }
public void SuperTime() { // Next iteration PteraMover.ActivateTimeFreeze(); CaveFlamePit.ActivateTimeFreeze(); Fireball.ActivateTimeFreeze(); DestroyByTime.ActivateTimeFreeze(); LaserBeam.ActivateTimeFreeze(); Saw.ActivateTimeFreeze(); LaserTurret.ActivateTimeFreeze(); SwingingBoulder[] sb = FindObjectsOfType <SwingingBoulder>(); sb[0].ActivateTimeFreeze(); sb[1].ActivateTimeFreeze(); sb[2].ActivateTimeFreeze(); sb[3].ActivateTimeFreeze(); sb[4].ActivateTimeFreeze(); sb[5].ActivateTimeFreeze(); sb[6].ActivateTimeFreeze(); RockController.ActivateTimeFreeze(); Turret.ActivateTimeFreeze(); PlayerController[] players = FindObjectsOfType <PlayerController>(); foreach (PlayerController p in players) { if (p.playerNumber != playerNumber) { p.timeFreezeActivated = true; p.GetComponent <Rigidbody2D>().isKinematic = true; p.anim.enabled = false; } } GameObject[] FXs = GameObject.FindGameObjectsWithTag("FX"); foreach (GameObject fx in FXs) { fx.GetComponent <ParticleSystem>().Pause(); } Arrow.ActivateTimeFreeze(); Puma.ActivateTimeFreeze(); Piranha.ActivateTimeFreeze(); Cobra.ActivateTimeFreeze(); Saw.ActivateTimeFreeze(); Banana.ActivateTimeFreeze(); BananaSpawn[] bs = FindObjectsOfType <BananaSpawn>(); Bat.ActivateTimeFreeze(); bs[0].ActivateTimeFreeze(); bs[1].ActivateTimeFreeze(); bs[2].ActivateTimeFreeze(); // Add a trail to show the use of a super skill TrailRenderer trailRenderer = gameObject.GetComponentInChildren <TrailRenderer>(); trailRenderer.enabled = true; }
private IEnumerator AutoMine() { while (true) { _rc = GetRockController(); while (_rc != null) { _rc.Hit(CalculateHitStrength()); yield return(new WaitForSeconds((float)GameController.Instance.GetMiningSpeed() / _miningSpeedMultiplier)); } yield return(null); } }
// Start is called before the first frame update void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); Ballista = GetComponent <Ballista>(); Bat = GetComponent <BatController>(); BoundTrap = GetComponent <BoundTrapController>(); Bush = GetComponent <BushController>(); Button = GetComponent <ButtonController>(); Crocodile = GetComponent <CrocodileController>(); Drop = GetComponent <DropController>(); FallingPlataform = GetComponent <FallingPlataform>(); //Pajaro = GameObject.FindGameObjectsWithTag("").GetComponent<ButtonController>(); Mole = GetComponent <MoloController>(); Mushroom = GetComponent <MushroomController>(); Rat = GetComponent <RatController>(); Rock = GetComponent <RockController>(); RotateTrap = GetComponent <RotateTrapController>(); Spawner = GetComponent <Spawner>(); Spikes = GetComponent <SpikesController>(); Thorms = GetComponent <ThormsController>(); Trap = GetComponent <TrapController>(); spriteRenderer.enabled = false; //Ballista.enabled = false; Bat.enabled = false; BoundTrap.enabled = false; Bush.enabled = false; Button.enabled = false; Crocodile.enabled = false; Drop.enabled = false; FallingPlataform.enabled = false; //Pajaro.enabled = false; Mole.enabled = false; Mushroom.enabled = false; Rat.enabled = false; Rock.enabled = false; RotateTrap.enabled = false; Spawner.enabled = false; Spikes.enabled = false; Thorms.enabled = false; Trap.enabled = false; }
public void boulderClicked(RockController controller) { int selectedVillagerCount = selectionManager.getSelectedVillagerCount(); if (selectedVillagerCount > 0) { // Harvest the rock List <VillagerMover> movers = selectionManager.getSelectedVillagerMovers(); for (int i = 0; i < movers.Count; i++) { movers[i].move(controller.gameObject.transform.position, true); movers[i].GetComponent <VillagerGather>().setRockController(controller); } selectionManager.unselectAllVillagers(); characterUiManager.unselectAll(); } if (fishingRadialActive) { Destroy(fishingRadial); fishingRadialActive = false; } }
void Awake() { RC = this; }
// Use this for initialization void Start () { rockController = rock.GetComponent<RockController>(); }
public void setRockController(RockController controller) { rockController = controller; enrouteToBoulder = true; }
// Update is called once per frame void Update() { // Pausing if (pause) { return; } // Check if game over tick++; // Block spawning if (tick % blockInterval == 0) { int index = _rand.Next(0, block.Length); GameObject newBlock = Instantiate(block[index]); Vector3 randScaleVector = new Vector3(_rand.Next(0, 20) - 10, 0, _rand.Next(0, 20) - 10); // Direction Vector3 dir = newBlock.transform.position - player.transform.position + randScaleVector; newBlock.GetComponent <Rigidbody> ().velocity = blockSpeed * dir.normalized * -1; newBlock.transform.rotation = Quaternion.LookRotation(dir); newBlock.GetComponent <BlockController> ().gamePointsController = gamePointsController; } // Rock spawning if (tick % rockInterval == 0) { int index = _rand.Next(0, rock.Length); GameObject newRock = Instantiate(rock [index]); Destroy(newRock.gameObject, 15); // Play sound AudioSource.PlayClipAtPoint(rockThrowClip, newRock.transform.position, 1.5f); // Direction and speed Vector3 dir = -(newRock.transform.position - player.transform.position).normalized; RockController rockController = newRock.GetComponent <RockController> (); newRock.GetComponent <Rigidbody> ().velocity = new Vector3(rockController.speed * dir.x, rockController.angle, rockController.speed * dir.z); } // Axe spawning if (_axeController == null) { spawnAxe(); } else if (tick % axeSpawnInterval == 0) { if (_axeController.thrown) { spawnAxe(); } } if (tick % (rockInterval * blockInterval * axeSpawnInterval) == 0) { tick = 0; } }