Beispiel #1
0
    /**
     * 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;
        }
    }
Beispiel #2
0
    /// <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>();
        }
    }
Beispiel #3
0
    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);
        }
    }
Beispiel #4
0
 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;
 }
Beispiel #7
0
//	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;
     }
 }
Beispiel #9
0
 // 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>();
 }
Beispiel #10
0
    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);
        }
    }
Beispiel #11
0
 /// <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);
         }
     }
 }
Beispiel #12
0
 /// <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;
         }
     }
 }
Beispiel #13
0
 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();
 }
Beispiel #14
0
 /// <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;
     }
 }
Beispiel #15
0
 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();
 }
Beispiel #16
0
 /// <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);
         }
     }
 }
Beispiel #17
0
    /**
     * 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;
        }
    }
Beispiel #18
0
    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;
             }
         }
     }
 }
Beispiel #20
0
    /// <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;
    }
Beispiel #21
0
    /// <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;
    }
Beispiel #22
0
    /// <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);
            }
        }
    }
Beispiel #23
0
 public void Start()
 {
     player = FindObjectOfType <PlayerRobot>();
     Debug.Assert(player != null);
 }
Beispiel #24
0
 public void Apply(PlayerRobot p)
 {
     p.AddLife(20.0f);
 }
Beispiel #25
0
 public void Unapply(PlayerRobot p)
 {
 }
Beispiel #26
0
 /// <summary>
 /// Triggers the routine for firing the battery
 /// </summary>
 /// <param name="robot"></param>
 public void FireBattery(PlayerRobot robot)
 {
     StartCoroutine(BatteryFiredRoutine(robot));
 }
Beispiel #27
0
 public bool InteractWithYourself(PlayerRobot p)
 {
     return(false);
 }
Beispiel #28
0
 /// <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>();
 }
Beispiel #30
0
 /// <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));
 }