Inheritance: MonoBehaviour
Esempio n. 1
0
    private void AssignSecondaryMechControls(GameObject newMech, MechController m1, MechController m2)
    {
        MechController mechController = newMech.GetComponent <MechController>();
        int            maxHealth      = 20;
        int            currentHealth  = m1.players[0].currentHealth + m2.players[0].currentHealth;

        float random = Random.Range(0f, 1f);

        if (random > 0.5f)
        {
            //assuming primary mechs have only one player
            m1.players[0].AssignNewMech(mechController, Player.MechControl.Movement, maxHealth, currentHealth);
            m2.players[0].AssignNewMech(mechController, Player.MechControl.Shoot, maxHealth, currentHealth);
        }
        else
        {
            m1.players[0].AssignNewMech(mechController, Player.MechControl.Shoot, maxHealth, currentHealth);
            m2.players[0].AssignNewMech(mechController, Player.MechControl.Movement, maxHealth, currentHealth);
        }

        //give mech it's new players
        List <Player> mechPlayers = new List <Player>(2);

        mechPlayers.Add(m1.players[0]);
        mechPlayers.Add(m2.players[0]);
        mechController.players = mechPlayers;

        //remove old players
        m1.players = new List <Player>(3);
        m2.players = new List <Player>(3);
    }
Esempio n. 2
0
    public void SpawnMech(Loadout loadout)
    {
        GameObject mech = Instantiate(baseMech);

        mech.transform.position = SpawnPoints[0].transform.position;

        // Set top frame model
        MeshFilter   mechTorsoMeshFilter = mech.transform.GetChild(0).GetComponent <MeshFilter>();
        MeshCollider meshTorsoCollider   = mech.transform.GetChild(0).GetComponent <MeshCollider>();

        mechTorsoMeshFilter.mesh     = loadout.TopFrame.Model;
        meshTorsoCollider.sharedMesh = mechTorsoMeshFilter.sharedMesh;

        //Set bottom frame model
        MeshFilter   mechBottomMeshFilter = mech.transform.GetChild(1).GetComponent <MeshFilter>();
        MeshCollider meshBottomCollider   = mech.transform.GetChild(1).GetComponent <MeshCollider>();

        mechBottomMeshFilter.mesh     = loadout.BottomFrame.Model;
        meshBottomCollider.sharedMesh = mechBottomMeshFilter.sharedMesh;

        // Set top frame health
        mechTorsoMeshFilter.GetComponent <Health>().BaseMaxHealth = loadout.TopFrame.Health;

        // Set bottom frame health
        mechBottomMeshFilter.GetComponent <Health>().BaseMaxHealth = loadout.BottomFrame.Health;

        MechController controller = mech.GetComponent <MechController>();

        controller.Loadout = loadout;
    }
Esempio n. 3
0
 private void RemoveFromHitList(MechController mech)
 {
     if (livedMechs.Contains(mech))
     {
         livedMechs.Remove(mech);
     }
 }
Esempio n. 4
0
    public override void Activate(MechController activator)
    {
        base.Activate(activator);

        PlayerController playerController = (PlayerController)activator;
        DoorOpen(playerController);
    }
Esempio n. 5
0
 public MoveState_Boosting(MechController controller)
     : base(controller)
 {
     if(controller.GetType() == typeof(PlayerController)) {
         playerController = (PlayerController)controller;
     }
 }
Esempio n. 6
0
    private void SetUnitAim(MechController enemy)
    {
        var dist  = Random.Range(1.0f, 2.5f);
        var point = playerMech.transform.position + new Vector3(Random.Range(-dist, dist), 0, Random.Range(-dist, dist));

        enemy.FireTo(point);
    }
Esempio n. 7
0
 private void Awake()
 {
     playerHandler  = mechObject.GetComponentInParent <PlayerHandler>();
     mechController = playerHandler.MechController;
     thrusterTimer  = zero;
     rocketJump     = GetComponent <RocketJump>();
 }
Esempio n. 8
0
 private void DisbandMech(MechController mech)
 {
     if (mech.transform == _targetTransform)
     {
         _targetTransform = MechFactory.Instance.GetRandomActiveMech();
     }
 }
Esempio n. 9
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag == "MergeArea")
        {
            MechController myMech    = GetComponentInParent <MechController>();
            MechController otherMech = col.GetComponentInParent <MechController>();
            if (myMech != null && otherMech != null)
            {
                if (MergeMechs != null)
                {
                    MergeMechs(myMech, otherMech);
                    combineAnimator.SetTrigger("Triple");
                }
            }

            /*
             * switch (myMech.mechColour)
             * {
             *      case MechController.MechColour.Red:
             *              if (otherMech.mechColour == MechController.MechColour.Blue)
             *              {
             *                      Debug.Log("NO PURPLE MECH YET");
             *
             *              }
             *              else if (otherMech.mechColour == MechController.MechColour.Yellow)
             *              {
             *                      Debug.Log("NO ORANGE MECH YET");
             *              }
             *              break;
             *      case MechController.MechColour.Blue:
             *              if (otherMech.mechColour == MechController.MechColour.Red)
             *              {
             *                      Debug.Log("NO PURPLE MECH YET");
             *
             *              }
             *              else if (otherMech.mechColour == MechController.MechColour.Yellow)
             *              {
             *                      Debug.Log("NO GREEN MECH YET");
             *              }
             *              break;
             *      case MechController.MechColour.Yellow:
             *              if (otherMech.mechColour == MechController.MechColour.Blue)
             *              {
             *                      Debug.Log("NO GREEN MECH YET");
             *              }
             *              else if (otherMech.mechColour == MechController.MechColour.Red)
             *              {
             *                      Debug.Log("NO Orange MECH YET");
             *              }
             *              break;
             *      case MechController.MechColour.Purple://...or any other secondary
             *              Debug.Log("NO RAINBOW MECH YET");
             *              break;
             * }
             */
        }
    }
Esempio n. 10
0
 private void Start()
 {
     Mech           = GetComponent <MechController>();
     Game           = GetComponent <MechController>().Game;
     loadout        = GetComponent <MechController>().Loadout;
     dualTimer      = GetComponents <Timer>().FirstOrDefault(t => t.Name == DualTimerName);
     mainWeapons[0] = loadout.WeaponLeft;
     mainWeapons[1] = loadout.WeaponRight;
 }
Esempio n. 11
0
 void Awake()
 {
     playerHandler      = GetComponentInParent <PlayerHandler>();
     mechController     = GetComponent <MechController>();
     firstPersonCamera  = GetComponent <FirstPersonCamera>();
     projectileLauncher = GetComponent <ProjectileLauncher>();
     dashing            = GetComponent <Dashing>();
     viewModelControl   = GetComponent <ViewmodelControl>();
 }
Esempio n. 12
0
    /// <summary>
    /// health the activator
    /// </summary>
    public override void Activate(MechController activator)
    {
        if(activator != null & activator.MechComponent != null) {
            Debug.Log("[" + name + "] Heals [" + activator.name + "] for " + healAmount);
            activator.MechComponent.AddHealth(healAmount, gameObject);
        }

        base.Activate(activator);
    }
Esempio n. 13
0
    /// <summary>
    /// Player has picked up this item
    /// </summary>
    public virtual void Activate(MechController activator)
    {
        hasBeenActivated = true;

        if(pickupSound != null) {
            WorldManager.instance.PlayGlobalSound(pickupSound);
        }

        gameObject.SetActive(false);
    }
Esempio n. 14
0
    private MechColour GetMergedMechColour(MechController m1, MechController m2)
    {
        MechColour mechColour = MechColour.Red;

        if (m1.mechColour == MechColour.Purple || m1.mechColour == MechColour.Orange || m1.mechColour == MechColour.Green ||
            m2.mechColour == MechColour.Purple || m2.mechColour == MechColour.Orange || m2.mechColour == MechColour.Green)
        {
            mechColour = MechColour.Rainbow;
        }
        else
        {
            switch (m1.mechColour)
            {
            case MechController.MechColour.Red:
                if (m2.mechColour == MechController.MechColour.Blue)
                {
                    mechColour = MechColour.Purple;
                }
                else if (m2.mechColour == MechController.MechColour.Yellow)
                {
                    mechColour = MechColour.Orange;
                }
                break;

            case MechController.MechColour.Blue:
                if (m2.mechColour == MechController.MechColour.Red)
                {
                    mechColour = MechColour.Purple;
                }
                else if (m2.mechColour == MechController.MechColour.Yellow)
                {
                    mechColour = MechColour.Green;
                }
                break;

            case MechController.MechColour.Yellow:
                if (m2.mechColour == MechController.MechColour.Blue)
                {
                    mechColour = MechColour.Green;
                }
                else if (m2.mechColour == MechController.MechColour.Red)
                {
                    mechColour = MechColour.Orange;
                }
                break;

            default:
                Debug.LogError("Failed to get correct mech colour combination!!! making a second red");
                mechColour = MechColour.Red;
                break;
            }
        }

        return(mechColour);
    }
Esempio n. 15
0
    public override void Activate(MechController activator)
    {
        // Add ythe points ot the player state
        if(WorldManager.instance.playerState != null) {
            WorldManager.instance.playerState.CollectPoints(pointsValue);
        }

        // TODO: sound

        base.Activate(activator);
    }
Esempio n. 16
0
    private void MergeMechs(MechController m1, MechController m2)
    {
        MechColour newMechColour = GetMergedMechColour(m1, m2);
        Vector2    spawnPosition = (m1.transform.position + m2.transform.position) / 2;

        if (_activeMechColours.Contains(newMechColour) == false)
        {
            if (newMechColour == MechColour.Purple)
            {
                ShowMech(PurpleMech, spawnPosition);
                AssignSecondaryMechControls(PurpleMech, m1, m2);
                HideMech(RedMech);
                HideMech(BlueMech);
                SendMergeUpdate(m1.transform, m2.transform, PurpleMech.transform);
            }
            else if (newMechColour == MechColour.Orange)
            {
                ShowMech(OrangeMech, spawnPosition);
                AssignSecondaryMechControls(OrangeMech, m1, m2);
                HideMech(RedMech);
                HideMech(YellowMech);
                SendMergeUpdate(m1.transform, m2.transform, OrangeMech.transform);
            }
            else if (newMechColour == MechColour.Green)
            {
                ShowMech(GreenMech, spawnPosition);
                AssignSecondaryMechControls(GreenMech, m1, m2);
                HideMech(BlueMech);
                HideMech(YellowMech);
                SendMergeUpdate(m1.transform, m2.transform, GreenMech.transform);
            }
            else if (newMechColour == MechColour.Rainbow)
            {
                ShowMech(RainbowMech, spawnPosition);
                AssignTertiaryMechControls(m1, m2);
                HideMech(BlueMech);
                HideMech(YellowMech);
                HideMech(RedMech);
                HideMech(GreenMech);
                HideMech(OrangeMech);
                HideMech(PurpleMech);
                SendMergeUpdate(m1.transform, m2.transform, RainbowMech.transform);
            }

            m1.SetMergingState(false);
            m2.SetMergingState(false);

            _activeMechColours.Add(newMechColour);
            _activeMechColours.Remove(m1.mechColour);
            _activeMechColours.Remove(m2.mechColour);
        }
    }
Esempio n. 17
0
    private void Awake()
    {
        startingMech = activeMech;
        input        = new PlayerControls();

        //player input can handle the device assignment, but we need to set it to match our control scheme
        _playerInput  = GetComponent <PlayerInput>();
        input.devices = _playerInput.devices;

        SetInputMappings();

        AssignNewMech(activeMech, MechControl.Full, 10, 10);
        AdjustHealth(0);
    }
Esempio n. 18
0
    /// <summary>
    /// Called to clear the target fog
    /// </summary>
    public virtual void Activate(MechController activator)
    {
        // check that it hasnt already been actiavted
        if(hasBeenActivated) {
            return;
        }

        hasBeenActivated = true;
        if(targetFog != null && !targetFog.HasBeenCleared) {
            targetFog.ClearFog();
        }

        Debug.Log("Room Access object " + gameObject.name + " activated...");
        WorldManager.instance.PlayGlobalSound(onActivatedSound);
    }
Esempio n. 19
0
    private void Awake()
    {
        // Setting max values to inspector values.
        mechMaxHealth = mechHealth;
        coreMaxHealth = coreHealth;

        stateManager = GetComponent <StateManager>();
        playerStats  = GetComponent <PlayerStatistics>();

        coreRB        = coreObject.GetComponentInChildren <Rigidbody>();
        coreTransform = coreObject.GetComponent <Transform>();

        mechController      = mechObject.GetComponent <MechController>();
        characterController = mechObject.GetComponent <CharacterController>();
        mechTransform       = mechObject.GetComponent <Transform>();
        impactReceiver      = mechObject.GetComponent <ImpactReceiver>();

        mechCamera = mechObject.GetComponent <FirstPersonCamera>();
    }
Esempio n. 20
0
   void Awake()
   {
      Proto = GetComponent<ProtoMech>();
      Controller = GetComponent<MechController>();
      Weapons = GetComponentsInChildren<Weapon>();
      if (Weapons.Length != 2)
      {
         Debug.LogWarning("Found more or less than 2 weapons on mech.");
      }

      // Assign Each Weapon a unique Index to facility communications between
      // the Mech and its weapons
      for (int weapIdx = 0; weapIdx < Weapons.Length; weapIdx++)
         Weapons[weapIdx].WeaponIndex = weapIdx;

      if (isServer)
      {
         CurrentState = MechState.Inactive;
      }
   }
Esempio n. 21
0
    // Start is called before the first frame update
    void Start()
    {
        mechManager    = GetComponent <MechManager>();
        mechController = GetComponent <MechController>();

        weaponGroups.Add(new WeaponGroup());
        weaponGroups.Add(new WeaponGroup());
        weaponGroups.Add(new WeaponGroup());

        for (int secIndex = (int)SectionIndex.leftArm; secIndex < (int)SectionIndex.rightShoulder; secIndex++)
        {
            weaponExecutables.AddRange(mechManager.GetExecutableByIndex(secIndex));
        }

        for (int i = 0; i < weaponExecutables.Count; i++)
        {
            weaponExecutables[i].refSystem = this;
            weaponGroups[(int)weaponExecutables[i].weaponItemRef.weaponClass].mappedWeapons.Add(weaponExecutables[i]);
        }
    }
Esempio n. 22
0
    public void AssignNewMech(MechController mech, MechControl control, int maxHealth, int health)
    {
        activeMech = mech;

        switch (control)
        {
        case MechControl.Full:
            //_playerInput.SwitchCurrentActionMap("FullControl"); /// used to switch the current action map, but didn't notice the diffference
            input.MovementControl.Enable();
            input.ShootControl.Enable();
            input.SecondaryShootControl.Enable();

            break;

        case MechControl.Movement:
            //_playerInput.SwitchCurrentActionMap("MovementControl");
            input.MovementControl.Enable();
            input.ShootControl.Disable();
            input.SecondaryShootControl.Disable();

            break;

        case MechControl.Shoot:
            //_playerInput.SwitchCurrentActionMap("ShootControl");
            input.MovementControl.Disable();
            input.ShootControl.Enable();
            input.SecondaryShootControl.Disable();

            break;

        case MechControl.SecondaryShoot:
            input.SecondaryShootControl.Enable();
            input.MovementControl.Disable();
            input.ShootControl.Disable();
            break;
        }
        playerUI.SetColour(mech.mechColour);
        playerUI.MaxHealth = maxHealth;
        this.currentHealth = health;
        AdjustHealth(0);
    }
Esempio n. 23
0
 private void Update()
 {
     if (delayTimer > 0)
     {
         delayTimer -= Time.deltaTime;
         return;
     }
     if (timer > 0)
     {
         timer -= Time.deltaTime;
         var normalizedTime = timer / flyTime;
         var centralTime    = normalizedTime * 2f - 1f;
         transform.position = Vector3.Lerp(targetPosition, startPosition, normalizedTime) + Vector3.up * (distance * 0.4f * (1f - centralTime * centralTime));
     }
     else
     {
         gameObject.SetActive(false);
         MechController.BlowMechsInPosition(targetPosition, hitRadius, 1);
         Effects.Blow(targetPosition);
         Game.Stress(0.3f);
     }
 }
Esempio n. 24
0
    //should just be used for rainbow
    private void AssignTertiaryMechControls(MechController m1, MechController m2)
    {
        MechController mechController = RainbowMech.GetComponent <MechController>();
        List <Player>  players        = new List <Player>(3);

        players.AddRange(m1.players);
        players.AddRange(m2.players);
        int maxHealth     = 30;
        int currentHealth = m1.players[0].currentHealth + m2.players[0].currentHealth;

        //TODO: Randomise role assignments
        //all playes need to be assigned a new mech with a role
        players[0].AssignNewMech(mechController, Player.MechControl.Shoot, maxHealth, currentHealth);
        players[1].AssignNewMech(mechController, Player.MechControl.SecondaryShoot, maxHealth, currentHealth);
        players[2].AssignNewMech(mechController, Player.MechControl.Movement, maxHealth, currentHealth);

        //give rainbow mech it's new players
        mechController.players = players;

        //remove old players
        //remove old players
        m1.players = new List <Player>(3);
        m2.players = new List <Player>(3);
    }
Esempio n. 25
0
    /// <summary>
    /// Called when this weapon is equipped onto a mech
    /// </summary>
    public virtual void OnEquip(MechController controller, bool usesAmmo = true)
    {
        currentAmmo = baseAmmo;
        consumesAmmo = usesAmmo;
        owner = controller;

        GetRenderer().enabled = true;
    }
Esempio n. 26
0
 public MoveState_Normal(MechController controller)
     : base(controller)
 {
 }
Esempio n. 27
0
 /// <summary>
 /// Instructs the ai to start sensing for a target (does not mean it will actually start chasing and shooting)
 /// </summary>
 public virtual void AiStartSensing()
 {
     // TODO: better way of assigning target
     target = GameObject.FindObjectOfType<PlayerController>();
     SetCanMove(true);
 }
Esempio n. 28
0
 /// <summary>
 /// Called from controller component when this mech is spawned by world manager
 /// </summary>
 public virtual void OnSpawnInitialization()
 {
     controller = GetComponent<MechController>();
 }
Esempio n. 29
0
    /// <summary>
    /// Overriden to account for shield absorbtion effect
    /// </summary>
    public override void TakeDamage(float damageAmount, MechController instigator, Weapon weaponUsed)
    {
        if(IsDead || isFalling) {
            return;
        }

        // Check if friendly fire is allowed
        if(weaponUsed != null) {
            if(instigator.mechTeam == controller.mechTeam && !WorldManager.instance.friendlyFire) {
                return;
            }
        }

        float modifiedDamage = instigator != null? instigator.ModifyBaseDamage(damageAmount, weaponUsed) : damageAmount;
        float reducedDamage = modifiedDamage;

        bool armorReducesDamage = true;

        // Account for the armor weaknesses from the weapon type
        if(armorWeaknessList.Length > 0 && weaponUsed != null) {
            // this armor has a weakness, check if the weapon has a strength against that weakness
            for(int i = 0; i < armorWeaknessList.Length; i++) {
                for(int j = 0; j < weaponUsed.damageTypeList.Length; j++) {
                    if(armorWeaknessList[i] == weaponUsed.damageTypeList[j]) {
                        // then the damage is not reduced any more, because this weapon is strong against this weakness
                        armorReducesDamage = false;
                    }
                }
            }
        }

        if(armorReducesDamage) {
            float priorDamage = reducedDamage;
            reducedDamage = (1.0f - armorProtection) * reducedDamage;
        }

        // Take the damage out of the shield first: changed system to only use energy bar
        //float shieldAbsorbtion = Mathf.Min(currentShield, reducedDamage);
        //currentShield -= shieldAbsorbtion;

        // the damage is going to deplete the shield energy, and there is currently shield energy
        if(currentEnergyLevel > 0.0f && reducedDamage > currentEnergyLevel &&
            shieldDepletedSound != null) {
            if(Time.time - lastShieldDepletedTime > minShieldDepletedTime) {
                lastShieldDepletedTime = Time.time;
                WorldManager.instance.PlayGlobalSound(shieldDepletedSound);
            }
        }

        float shieldAbsorbtion = ConsumeEnergy(reducedDamage);

        // And reduce the damage that is done to health
        reducedDamage -= shieldAbsorbtion;

        if(damageHandlerCallback != null) {
            damageHandlerCallback(reducedDamage);
        }

        // Check if the health is above the "low" threshold before applying damage
        const float lowHealthRatio = 0.5f;
        float lowHealthThreshold = (maxhealth + controller.GetHealthModifier()) * lowHealthRatio;

        bool wasAboveThreshold = health >= lowHealthThreshold;

        base.TakeDamage(reducedDamage, instigator, weaponUsed);

        // Check if the actor is at low health (given by some arbitrary ratio) and play a sound if there is one set
        if(lowHealthSound != null && Time.time - lastLowHealthTime > minLowHealthThresholdTime &&
            wasAboveThreshold && health < lowHealthThreshold) { // it is now below, and previously was above
            WorldManager.instance.PlayGlobalSound(lowHealthSound);

            lastLowHealthTime = Time.time;
        }
    }
Esempio n. 30
0
    /// <summary>
    /// Start
    /// Pretty much everything that we do in MechUserControl we 
    /// only do for the local player..
    /// </summary>
    private void Start()
    {
        if (!isLocalPlayer)
         return;

          // get the transform of the main camera
          if (Camera.main != null)
          {
         m_Cam = Camera.main.transform;
          }
          else
          {
         Debug.LogWarning(
               "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
         // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
          }

          // get the third person character ( this should never be null due to require component )
          m_MechController = GetComponent<MechController>();
          m_Mech = GetComponent<Mech>();
    }
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     cc    = animator.transform.parent.gameObject.GetComponent <CharacterController>();
     mctrl = animator.transform.parent.gameObject.GetComponent <MechController>();
     mcbt  = animator.transform.parent.gameObject.GetComponent <MechCombat>();
 }
Esempio n. 32
0
    protected override float DoDeathSequence(MechController instigator, Weapon weaponUsed)
    {
        //if(instigator.GetType() != typeof(PlayerController)) {
        //    return 0.0f;
        //}

        const float delayLength = 0.0f;
        const float knowckbackForce = 0.0f;

        isDead = true;

        if(deathExplosion != null) {
            Explosion deathExplosionInstance = (Explosion)Instantiate(deathExplosion, transform.position, Quaternion.identity);
            if(deathExplosionInstance != null) {
                deathExplosionInstance.Explode(weaponUsed);
            }
        }

        if(instigator != null) {
            // So it was killed by the player, do a fancy death sequence where it shoots away from the palyer
            AddForce((transform.position - instigator.transform.position).normalized, knowckbackForce);
            controller.SetControllerActive(false);
        }

        return delayLength;
    }
Esempio n. 33
0
    public override void OnEquip(MechController controller, bool usesAmmo = true)
    {
        base.OnEquip(controller, usesAmmo);

        currentEnergy = baseAmmo;
    }
Esempio n. 34
0
    private void MoveRandomDirection(MechController enemy)
    {
        var randomPosition = new Vector3(Random.Range(minFieldPoint.x, maxFieldPoint.x), 0, Random.Range(minFieldPoint.y, maxFieldPoint.y));

        enemy.MoveTo(randomPosition);
    }
Esempio n. 35
0
    private void DisbandMech(MechController mech)
    {
        Vector2 oldMechPos = mech.transform.position;

        //depending on colour....
        if (mech.mechColour == MechColour.Orange)
        {
            HideMech(OrangeMech);
            ShowMech(RedMech, oldMechPos + new Vector2(-1, 0));
            ShowMech(YellowMech, oldMechPos + new Vector2(1, 0));

            _activeMechColours.Remove(MechColour.Orange);
            _activeMechColours.Add(MechColour.Red);
            _activeMechColours.Add(MechColour.Yellow);
        }
        else if (mech.mechColour == MechColour.Purple)
        {
            HideMech(PurpleMech);
            ShowMech(RedMech, oldMechPos + new Vector2(-1, 0));
            ShowMech(BlueMech, oldMechPos + new Vector2(1, 0));

            _activeMechColours.Remove(MechColour.Purple);
            _activeMechColours.Add(MechColour.Red);
            _activeMechColours.Add(MechColour.Blue);
        }
        else if (mech.mechColour == MechColour.Green)
        {
            HideMech(GreenMech);
            ShowMech(YellowMech, oldMechPos + new Vector2(-1, 0));
            ShowMech(BlueMech, oldMechPos + new Vector2(1, 0));

            _activeMechColours.Remove(MechColour.Green);
            _activeMechColours.Add(MechColour.Blue);
            _activeMechColours.Add(MechColour.Yellow);
        }
        else if (mech.mechColour == MechColour.Rainbow)
        {
            HideMech(RainbowMech);
            ShowMech(YellowMech, oldMechPos + new Vector2(-1, 0));
            ShowMech(BlueMech, oldMechPos + new Vector2(1, 0));
            ShowMech(RedMech, oldMechPos + new Vector2(0, 1));

            _activeMechColours.Remove(MechColour.Rainbow);
            _activeMechColours.Add(MechColour.Blue);
            _activeMechColours.Add(MechColour.Yellow);
            _activeMechColours.Add(MechColour.Red);
        }
        //reassign controls
        int splitHealth = 10;

        if (mech.mechColour == MechColour.Green || mech.mechColour == MechColour.Purple || mech.mechColour == MechColour.Orange)
        {
            splitHealth = Mathf.CeilToInt(mech.players[0].currentHealth / 2f);
        }
        else if (mech.mechColour == MechColour.Red || mech.mechColour == MechColour.Blue || mech.mechColour == MechColour.Yellow)
        {
            splitHealth = Mathf.CeilToInt(mech.players[0].currentHealth / 3f);
        }

        foreach (Player player in mech.players)
        {
            player.AssignStartingMech(splitHealth);
            player.activeMech.players = new List <Player>()
            {
                player
            };
        }
        //create lower level mechs
        //assign controls
        //remove upper level mech
    }
Esempio n. 36
0
    /// <summary>
    /// Applies the damage to the actor
    /// </summary>
    public virtual void TakeDamage(float damageAmount, MechController instigator, Weapon weaponUsed)
    {
        if(isDead) {
            return;
        }

        if(canTakeDamageRequest != null && !canTakeDamageRequest(instigator.gameObject)) {
            return;
        }

        if(weaponUsed != null) {
            damageAmount = damageAmount * weaponUsed.ai_DamageScale;
        }

        health -= damageAmount;

        if(health <= 0.0f) {
            health = 0.0f;

            float deathSequenceLength = DoDeathSequence(instigator, weaponUsed);
            if(deathSequenceLength == 0.0f) {
                Died();
            }
            else {
                StartCoroutine(DelayedDeath(deathSequenceLength));
            }
        }

        lastReceivedDamage = Time.time;
    }
Esempio n. 37
0
 /// <summary>
 /// Does the death sequence, and returns how long the death sequence is
 /// </summary>
 protected virtual float DoDeathSequence(MechController instigator, Weapon weaponUsed)
 {
     return 0.0f;
 }