/** * Apply random bonus to player */ public void Apply(PlayerRobot p, int bonusType) { if (isActive) { return; } _player = p; this.EnableBonus(); switch (bonusType) { case LIFE_BONUS: applicator = new LifeBonus(); applicator.Apply(_player); Level.DisplayAnnounce("Life!"); Invoke("DisableBonus", applicator.duration); break; case SHIELD_BONUS: applicator = new ShieldBonus(); applicator.Apply(_player); Level.DisplayAnnounce("Shield!"); Invoke("DisableBonus", applicator.duration); break; case INVINCIBILITY_BONUS: applicator = new InvincibilityBonus(); applicator.Apply(_player); Level.DisplayAnnounce("Invincibility!"); Invoke("DisableBonus", applicator.duration); break; } }
/// <summary> /// Attaches to the conveyor belt only when: /// - The player that fired it is not on the same conveyor belt /// - Removes reference to robot that fired it when it attches to the conveyor belt /// /// Otherwise /// - If a robot is within range then sets a reference to its battery back /// /// </summary> /// <param name="other"></param> void OnTriggerEnter(Collider other) { if (OnConveyorBelt == null && !Attached && other.CompareTag("ConveyorBelt")) { var conveyor = other.GetComponentInParent <ConveyorBelt>(); if (conveyor != null && conveyor.IsRunning) { // Ignore conveyor trigger since the robot who shot the battery is on it if (m_firedFromRobot != null && conveyor.RobotOnConveyor(m_firedFromRobot)) { return; } // Good to attach m_firedFromRobot = null; OnConveyorBelt = conveyor; RB.velocity = Vector3.zero; } } else if (other.CompareTag("PlayerBatterySlot")) { m_playerBatteryInRange = other.gameObject.GetComponentInParent <PlayerRobot>(); } }
void Shoot() { Vector3 o = new Vector3(transform.position.x, transform.position.y + 4.0f, transform.position.z); gunLight.enabled = true; gunLine.enabled = true; shootRay.origin = o; shootRay.direction = -transform.forward; gunLine.SetPosition(0, o); gunLine.SetPosition(1, o + shootRay.direction * 50); //Si rayon touche objet if (Physics.Raycast(shootRay, out shootHit)) { PlayerRobot playerHit = shootHit.collider.GetComponent <PlayerRobot> (); if (playerHit != null) { playerHit.ReceiveDamages(damage); } gunLine.SetPosition(1, shootHit.point); } }
void Start() { levelManager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <LevelManager>(); playerBot = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerRobot>(); endPosition = transform.localPosition; endRotation = transform.eulerAngles; moveToPoint = true; }
public void SetTargetControl(Transform player, MultiContolBase control) { playerRobot = new PlayerRobot(); playerRobot.SetCameraHands(HUDCamera, rightHand, leftHand); playerRobot.Init(player); targetControl = control; //player.gameObject.SetActive(false); }
// Start is called before the first frame update public override void Init() { body = transform.Find("Body"); arm = body.Find("Arm"); hand = arm.Find("Hand"); armInitY = arm.localPosition.y; robot = GameObject.Find("[CameraRig]").GetComponent <PlayerControl>().playerRobot; // test = GameObject.Find("Sphere").transform; }
// AudioSource shootingSound; // Audio // Use this for initialization void Start() { gunParticle = GetComponent <ParticleSystem>(); gunLine = GetComponent <LineRenderer>(); gunLight = GetComponent <Light>(); robot = transform.parent.parent.parent.parent.GetComponent <PlayerRobot> (); // Sorry for this ugly stuff weapon = robot.weapon; cadence = weapon.rate; damage = weapon.damage; }
/// <summary> /// Changes the robot being controlled /// </summary> /// <param name="robot"></param> public void SwitchRobot(PlayerRobot robot) { if (robot != null) { // Should always be done but it does not hurt CurrentPlayerRobot.PoweredOn = false; robot.PoweredOn = true; CurrentPlayerRobot = robot; } }
// Use this for initialization void Start() { //实例化核心 _mPlayerRobot = new PlayerRobot(this, new FireCore(), MoveSpeed); //开启每秒时间协程 StartCoroutine(_mPlayerRobot.SecondEvent()); SR = GetComponent <SpriteRenderer>(); AS = GetComponent <AudioSource>(); Anim = GetComponent <Animator>(); }
void Shoot() { if (robot.isAlive == false) { return; } weapon = robot.weapon; cadence = weapon.rate; damage = weapon.damage; weapon.PlaySound(); timer = 0; gunLight.enabled = true; gunParticle.Stop(); gunParticle.Play(); gunLine.enabled = true; shootRay.origin = transform.position; shootRay.direction = transform.forward; gunLine.SetPosition(0, transform.position + shootRay.direction * 100); gunLine.SetPosition(1, transform.position); if (weapon.isRoulette) { int r = Random.Range(1, 3); if (r != 2) { // Shoot on player robot.ReceiveDamages((damage / 4.0f)); return; } } //Si rayon touche objet if (Physics.Raycast(shootRay, out shootHit)) { PlayerRobot playerHit = shootHit.collider.GetComponent <PlayerRobot> (); if (playerHit != null) { playerHit.ReceiveDamages((damage / 4.0f)); } gunLine.SetPosition(0, shootHit.point); } }
/// <summary> /// Removes robots from the list /// </summary> /// <param name="other"></param> void OnTriggerExit(Collider other) { if (other.CompareTag("PlayerFeet")) { PlayerRobot robot = other.gameObject.GetComponentInParent <PlayerRobot>(); if (robot != null && m_robotsOnBelt.Contains(robot)) { m_robotsOnBelt.Remove(robot); } } }
/// <summary> /// Player left the tile /// </summary> /// <param name="other"></param> void OnTriggerExit(Collider other) { if (other.CompareTag("PlayerFeet")) { PlayerRobot robot = other.gameObject.GetComponentInParent <PlayerRobot>(); if (robot.PlayerColor == m_robotColor) { m_robotOnButton = null; IsActive = false; } } }
public void PlayerFinishedRecording() { gameRunning = false; Recorder.Recording rr = new Recorder.Recording(); rr = currentPlayer.GetComponent <Recorder>().GetRecording(); robotRecordings.Add(rr); ghost.Possess(); Destroy(currentPlayer.gameObject); currentPlayer = null; ghost.transform.position = winCam.position; StartGlobalPlayback(); }
/// <summary> /// Triggers the actions when the battery is no longer on the belt /// </summary> /// <param name="other"></param> void OnTriggerExit(Collider other) { if (OnConveyorBelt != null && other.CompareTag("ConveyorBelt")) { ConveyorBelt conveyor = other.gameObject.GetComponentInParent <ConveyorBelt>(); OnConveyorBeltExit(other.transform.forward, conveyor.MoveSpeed); } else if (other.CompareTag("PlayerBatterySlot")) { m_playerBatteryInRange = null; } }
public void ClearTerminal() { if (commandList.transform.childCount > 0) { foreach (Transform child in commandList.transform) { Destroy(child.gameObject); } } playerRobot = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerRobot>(); inputField.ActivateInputField(); }
/// <summary> /// Player is on the tile /// </summary> /// <param name="other"></param> void OnTriggerEnter(Collider other) { if (other.CompareTag("PlayerFeet")) { PlayerRobot robot = other.gameObject.GetComponentInParent <PlayerRobot>(); if (robot.PlayerColor == m_robotColor) { m_robotOnButton = robot; IsActive = true; AudioManager.Instance.PlaySoundAt(AudioClipName.GoalTile, transform.position); } } }
/** * Called when player walk throught weapon box */ void OnTriggerEnter(Collider col) { if (isActive == false) { return; } PlayerRobot p = col.GetComponent <PlayerRobot> (); if (p) { Level.GetPlayerById(p.id).equipRandomWeapon(); renderer.enabled = false; isActive = false; } }
void OnTriggerEnter(Collider col) { if (isActive == false) { return; } PlayerRobot p = col.GetComponent <PlayerRobot> (); if (p) { Level.bonusManager.Apply(Level.GetPlayerById(p.id), bonusType); renderer.enabled = false; isActive = false; } }
/// <summary> /// Find the robot that starts powered ON /// Uses the first robot it finds ON /// Turns all other robots OFF /// </summary> void Start() { foreach (var robot in FindObjectsOfType <PlayerRobot>()) { if (robot.StartPoweredOn) { if (CurrentPlayerRobot == null) { CurrentPlayerRobot = robot; } else { robot.PoweredOn = false; } } } }
/// <summary> /// Fires the battery in the robot's forward direction /// </summary> /// <param name="robot"></param> /// <returns></returns> IEnumerator BatteryFiredRoutine(PlayerRobot robot) { // Power it down robot.PoweredOn = false; // Reset values m_firedFromRobot = robot; m_totalBounces = 0; m_colliderWithWall = false; // Update position RB.position = robot.BatterySlot.position; yield return(new WaitForFixedUpdate()); // Detache and show effects Attached = false; yield return(new WaitForEndOfFrame()); // Ensure collisions are being detected RB.detectCollisions = true; RB.velocity = robot.transform.forward * m_speed; }
/// <summary> /// Moves into the given robot's battery slot and powers it back on /// </summary> /// <param name="robot"></param> /// <returns></returns> IEnumerator AttachToRobotRoutine(PlayerRobot robot) { m_isAttaching = true; // Disable collisions until it is fired again m_rigidbody.detectCollisions = false; Vector3 destination = robot.BatterySlot.position; while (Vector3.Distance(m_rigidbody.position, destination) > .001f) { Vector3 towards = Vector3.MoveTowards(RB.position, destination, m_speed * Time.deltaTime); RB.MovePosition(towards); yield return(new WaitForEndOfFrame()); } RB.position = destination; Attached = true; PlayerController.Instance.SwitchRobot(robot); m_isAttaching = false; }
/// <summary> /// Valdiates that it can attach itself to a robot on tigger enter /// </summary> /// <param name="other"></param> void OnTriggerStay(Collider other) { // Attach to robot if (other.CompareTag("PlayerBatterySlot")) { PlayerRobot robot = other.gameObject.GetComponentInParent <PlayerRobot>(); if (robot == null) { return; } // Attach to new robot if (robot != m_firedFromRobot) { AttachToRobot(robot); // Allowed to re-attach to robot that fired it } else if (m_colliderWithWall) { AttachToRobot(m_firedFromRobot); } } }
public void Start() { player = FindObjectOfType <PlayerRobot>(); Debug.Assert(player != null); }
public void Apply(PlayerRobot p) { p.AddLife(20.0f); }
public void Unapply(PlayerRobot p) { }
/// <summary> /// Triggers the routine for firing the battery /// </summary> /// <param name="robot"></param> public void FireBattery(PlayerRobot robot) { StartCoroutine(BatteryFiredRoutine(robot)); }
public bool InteractWithYourself(PlayerRobot p) { return(false); }
/// <summary> /// True when the robot is on the conveyor belt /// </summary> /// <returns></returns> public bool RobotOnConveyor(PlayerRobot robot) { return(m_robotsOnBelt.Contains(robot)); }
public void Start() { player = FindObjectOfType <PlayerRobot>(); }
/// <summary> /// Triggers the routine for attaching itself to a robot /// </summary> /// <param name="robot"></param> public void AttachToRobot(PlayerRobot robot) { OnConveyorBelt = null; RB.velocity = Vector3.zero; StartCoroutine(AttachToRobotRoutine(robot)); }