void DeployCannon() { if (lives > 0) { ShowLives(); currentCannon = Instantiate(cannonSource); CannonControl cannonScript = currentCannon.GetComponent <CannonControl>(); cannonScript.slime = slime; cannonScript.pauseObj = pauseObj; cannonScript.touchpads = touchpads; puPad.SetActive(false); if (lives == 3) { slimescript.fetchPUs = true; } //if(lives == 1) //{ // LoadVideoAd(); // adManagerScript.SendMessage("LoadVideoAd"); //} //touchpads.SetActive(false); } else { pauseObj.tag = "Paused"; ShowLives(); timerscript.running = false; touchpads.SetActive(false); gameover.SetActive(true); pauseBtn.SetActive(false); ShowEnemGoldOnly(); slimescript.goldThisLvl = 0; } }
void Start() { rb2d = GetComponent <Rigidbody2D>(); bodyCollider = GetComponent <Collider2D>(); cannon = transform.GetComponentInChildren <CannonControl>(); movenmentTarget = Instantiate(movenmentTargetPrefab, transform.position, transform.rotation); movenmentTargetTrigger = movenmentTarget.GetComponent <Collider2D>(); audioSource = GetComponent <AudioSource>(); gameController = GameController.instance; }
void UnPauseGame() { if (currentCannon) { CannonControl cannonScript = currentCannon.GetComponent <CannonControl> (); cannonScript.SendMessage("UnPauseCannon"); } Slime slimeScript = slime.GetComponent <Slime> (); slimeScript.SendMessage("UnPauseSlime"); timerscript.run = true; }
void ExtraLife() { lives = 1; livesObj.GetComponent <Text>().text = "Lives: " + lives; currentCannon = Instantiate(cannonSource); CannonControl cannonScript = currentCannon.GetComponent <CannonControl>(); cannonScript.slime = slime; cannonScript.pauseObj = pauseObj; pauseObj.tag = "UnPaused"; timerscript.run = true; gameover.SetActive(false); pauseBtn.SetActive(true); }
private void OnTriggerStay2D(Collider2D collision) { //climbing ladders and ropes if ((collision.gameObject.CompareTag("Ladder")) || (collision.gameObject.CompareTag("Rope") && hasGem == false)) { climbspeed = 3; rb.gravityScale = 0; rb.velocity = new Vector2(rb.velocity.x, moveY * climbspeed); } else if (collision.gameObject.CompareTag("Rope") && hasGem) { climbspeed = 1.5f; rb.gravityScale = 0; rb.velocity = new Vector2(rb.velocity.x, moveY * climbspeed); } //interaction with gem if (collision.gameObject.CompareTag("Gem")) { atGem = true; if (interactCharge >= 0.5f) { Debug.Log("gem"); if (hasGem == false) { GemControl gemScript = collision.gameObject.GetComponent <GemControl>(); if (gemScript.isHeld == false) { hasGem = true; gemScript.isHeld = true; gemScript.holder = gameObject; } } else { hasGem = false; GemControl gemScript = collision.gameObject.GetComponent <GemControl>(); gemScript.isHeld = false; } interactCharge = 0; } } //interaction with cannon else if (collision.gameObject.CompareTag("Cannon")) { atCannon = true; if (interactCharge >= 0.5f) { Debug.Log("cannon"); CannonControl cc = collision.gameObject.GetComponent <CannonControl>(); cc.status = 1; interactCharge = 0; } } //interaction with switch if (collision.gameObject.CompareTag("Switch")) { atSwitch = true; if (interactCharge >= 0.5f) { Debug.Log("switch"); SwitchControl sc = collision.gameObject.GetComponent <SwitchControl>(); sc.switchflip = 1; interactCharge = 0; } } //interaction with supply if (collision.gameObject.CompareTag("Supply")) { atSupply = true; if (interactCharge >= 0.5f) { if (!hasBomb) { Debug.Log("supply"); hasBomb = true; mybomb.SetActive(true); } interactCharge = 0; } } }
public void setMetadata(InputManager.ControlID cID, CannonControl cc) { _fired_from_control_id = cID; _cc = cc; }
void Start() { cc = GameObject.FindGameObjectWithTag("Cannon").GetComponent <CannonControl>(); }
void Start() { cannon = transform.GetComponentInChildren <CannonControl>(); audioSource = GetComponent <AudioSource>(); gameController = GameController.instance; }
// Use this for initialization void Start() { cid1ismoving = false; cid2ismoving = false; cid3ismoving = false; cc1 = cannon1.GetComponent <CannonControl>(); cc2 = cannon2.GetComponent <CannonControl>(); cc3 = cannon3.GetComponent <CannonControl>(); pc1 = runner.GetComponent <PlayerControl>(); //pausedText.enabled = false; pausedMenu.SetActive(false); int joystickLength = 0; string[] Joysticks = Input.GetJoystickNames(); foreach (string thing in Joysticks) { if (thing != "") { joystickLength++; } } if (joystickLength > 0) // At least 1 controller attached. No need for Keyboard (Debug) Controller. { debugAllow = false; randomizePlayers(joystickLength); } else // No controllers attached! { debugAllow = true; randomizePlayers(1); // debugPlayerNum = getPlayerJoyNumForController(1); // whatever player 1 is controlling, control that. } PlayerColor c1 = getPlayerColorWithControlID(ControlID.Cannon1); PlayerColor c2 = getPlayerColorWithControlID(ControlID.Cannon2); PlayerColor c3 = getPlayerColorWithControlID(ControlID.Cannon3); PlayerColor rclr = getPlayerColorWithControlID(ControlID.Runner); if (c1 == PlayerColor.Red) { Debug.Log("IM SETTING THE COLOR1"); cannon1.GetComponent <CannonControl>().trueSetMaterial(player1Material); cannon1Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.red[0]; //cannon1.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player1Material); } else if (c1 == PlayerColor.Blue) { Debug.Log("IM SETTING THE COLOR2"); cannon1.GetComponent <CannonControl>().trueSetMaterial(player2Material); cannon1Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.blue[0]; //cannon1.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player2Material); } else if (c1 == PlayerColor.Green) { Debug.Log("IM SETTING THE COLOR3"); cannon1.GetComponent <CannonControl>().trueSetMaterial(player3Material); cannon1Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.green[0]; //cannon1.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player3Material); } else if (c1 == PlayerColor.Yellow) { Debug.Log("IM SETTING THE COLOR4"); cannon1.GetComponent <CannonControl>().trueSetMaterial(player4Material); cannon1Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.yellow[0]; //cannon1.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player4Material); } if (c2 == PlayerColor.Red) { cannon2.GetComponent <CannonControl>().trueSetMaterial(player1Material); cannon2Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.red[0]; //cannon2.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player1Material); } else if (c2 == PlayerColor.Blue) { cannon2.GetComponent <CannonControl>().trueSetMaterial(player2Material); cannon2Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.blue[0]; //cannon2.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player2Material); } else if (c2 == PlayerColor.Green) { cannon2.GetComponent <CannonControl>().trueSetMaterial(player3Material); cannon2Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.green[0]; //cannon2.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player3Material); } else if (c2 == PlayerColor.Yellow) { cannon2.GetComponent <CannonControl>().trueSetMaterial(player4Material); cannon2Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.yellow[0]; //cannon2.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player4Material); } if (c3 == PlayerColor.Red) { cannon3.GetComponent <CannonControl>().trueSetMaterial(player1Material); cannon3Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.red[0]; //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player1Material); } else if (c3 == PlayerColor.Blue) { cannon3.GetComponent <CannonControl>().trueSetMaterial(player2Material); cannon3Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.blue[0]; //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player2Material); } else if (c3 == PlayerColor.Green) { cannon3.GetComponent <CannonControl>().trueSetMaterial(player3Material); cannon3Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.green[0]; //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player3Material); } else if (c3 == PlayerColor.Yellow) { cannon3.GetComponent <CannonControl>().trueSetMaterial(player4Material); cannon3Sprite.GetComponent <SpriteRenderer>().sprite = CannonAnimation.C.yellow[0]; //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player4Material); } /* * print(rclr); * if (rclr == PlayerColor.Red) * { * runner.GetComponent<SpriteRenderer>().sprite = RunnerAnimation.R.red_left[0]; * //cannon3.GetComponent<CannonControl>().trueSetMaterial(player1Material); * //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player1Material); * } * else if (rclr == PlayerColor.Blue) * { * runner.GetComponent<SpriteRenderer>().sprite = RunnerAnimation.R.blue_left[0]; * //cannon3.GetComponent<CannonControl>().trueSetMaterial(player2Material); * //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player2Material); * } * else if (rclr == PlayerColor.Green) * { * runner.GetComponent<SpriteRenderer>().sprite = RunnerAnimation.R.green_left[0]; * //cannon3.GetComponent<CannonControl>().trueSetMaterial(player3Material); * //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player3Material); * } * else if (rclr == PlayerColor.Yellow) * { * runner.GetComponent<SpriteRenderer>().sprite = RunnerAnimation.R.yellow_left[0]; * //cannon3.GetComponent<CannonControl>().trueSetMaterial(player4Material); * //cannon3.GetComponent<CannonBallMetadata>().setCannonControlMaterial(player4Material); * }*/ }