Example #1
0
 // Use this for initialization
 new void Start()
 {
     base.Start();
     Weapon                 = new Weapon_Manager();
     Weapon.Unit            = Unit;
     Weapon.Damage          = 20;
     Weapon.HeadShot_Damage = 90;
     Weapon.Range           = 10;
     count     = 3;
     Item_Name = "Granade";
     Action    = false;
     Btn1      = false;
 }
Example #2
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         if (playerWeapon == null)
         {
             playerWeapon = other.GetComponent <Weapon_Manager>();
         }
         if (playerMovement == null)
         {
             playerMovement = other.GetComponent <EightWayMovement>();
         }
         playerWeapon.EnableWeapons();
         inRange = false;
     }
 }
 private void Start()
 {
     jump = gameObject.AddComponent <Jump>();
     jump.SetVals(jumpSpeed, MAX_JUMPS, wallJump, this);
     eightWayMovement = gameObject.AddComponent <EightWayMovement>();
     eightWayMovement.SetVals(walkingspeed, turnSpeed, RunningSpeed);
     dash = gameObject.AddComponent <Dash>();
     dash.SetVals(DashSpeed, dashDuration);
     weaponManager = gameObject.AddComponent <Weapon_Manager>();
     weaponManager.SetVals(InputType, items, gameObject, WeaponAttackObj, powerUpTime);
     playerHealth = gameObject.AddComponent <PlayerHealth>();
     playerHealth.SetVals(health, numOfHearts, hearts, fullHeart, emptyHeart);
     playerPickup = gameObject.AddComponent <Player_Pickup>();
     playerPickup.SetVals(SnapZone, throwForce, this);
     vehicle = gameObject.AddComponent <GetIntoVehicle>();
     vehicle.SetVal(this);
     pushScript = gameObject.AddComponent <Pushing_Script>();
     pushScript.SetVals(pushSpeed, this);
 }
Example #4
0
    public bool Hit(Weapon_Manager _Weapon)
    {
        float Total            = _Weapon.Unit.aim + _Weapon.Unit.PostureBonus + _Weapon.Aim_Bonus;
        int   Pressure_Bonus   = pressure - ((pressure / 100) * (will / 2));
        int   E_Pressure_Bonus = _Weapon.Unit.pressure - ((_Weapon.Unit.pressure / 100) * (_Weapon.Unit.will / 2));

        Total -= (DynamicVisualAcuity + PostureBonus);
        int I_Y = 0, I_X = 0;

        #region CoverBonus
        if (Mathf.Abs(x - _Weapon.Unit.x) > Mathf.Abs(y - _Weapon.Unit.y))
        {
            I_Y = 0;

            if (x > _Weapon.Unit.x)
            {
                I_X = -1;
            }
            else
            {
                I_X = 1;
            }
        }
        else
        {
            I_X = 0;

            if (y > _Weapon.Unit.y)
            {
                I_Y = -1;
            }
            else
            {
                I_Y = 1;
            }
        }

        if (_Tile.TileMap[x + I_X][y + I_Y] == Tile_Manager.Cover_Kind.HighCover)
        {
            CoverBonus = 50;
            Total     -= (CoverBonus - PostureBonus);
        }
        else if (_Tile.TileMap[x + I_X][y + I_Y] == Tile_Manager.Cover_Kind.HalfCover && (_Posture == Posture.Crouching || _Posture == Posture.Prone))
        {
            CoverBonus = 30;
            Total     -= (CoverBonus - PostureBonus);
        }
        else if (_Tile.TileMap[x + I_X][y + I_Y] == Tile_Manager.Cover_Kind.Debris && _Posture == Posture.Prone)
        {
            CoverBonus = 70;
            Total     -= (CoverBonus - PostureBonus);
        }

        //enemy
        if (_Tile.TileMap[_Weapon.Unit.x - I_X][_Weapon.Unit.y - I_Y] == Tile_Manager.Cover_Kind.HalfCover && _Weapon.Unit._Posture == Posture.Crouching)
        {
            Total += (10 - _Weapon.Unit.PostureBonus);
        }
        else if (_Tile.TileMap[_Weapon.Unit.x - I_X][_Weapon.Unit.y - I_Y] == Tile_Manager.Cover_Kind.HighCover)
        {
            Total -= _Weapon.Unit.PostureBonus;
        }
        #endregion

        #region Pressure Bonus
        if (Pressure_Bonus >= 90)
        {
            Total -= 8;
        }
        else if (Pressure_Bonus >= 80)
        {
            Total -= 5;
        }
        else if (Pressure_Bonus >= 60)
        {
            Total -= 2;
        }

        if (E_Pressure_Bonus >= 90)
        {
            Total -= 20;
        }
        else if (E_Pressure_Bonus >= 80)
        {
            Total -= 10;
        }
        else if (E_Pressure_Bonus >= 60)
        {
            Total -= 5;
        }
        #endregion

        Damage_UI _UI  = Instantiate(UI_Manager.Damage.gameObject, transform.position, Quaternion.identity).GetComponent <Damage_UI>();
        int       rand = Random.Range(0, 100);

        if (rand > Total)
        {
            _UI.SetText("MISS");
            pressure += 10;
            _Weapon.Unit.pressure -= 5;
            return(false);
        }
        else
        {
            rand = Random.Range(0, 100);


            if (rand < _Weapon.HeadShot_Percentage + _Weapon.Unit.HeadShotPercent + _Weapon.HeadShot_Bonus)
            {
                Health -= _Weapon.HeadShot_Damage;
                _UI.SetText("HeadShot " + _Weapon.HeadShot_Damage.ToString());
            }
            else
            {
                Health -= _Weapon.Damage;
                _UI.SetText(_Weapon.Damage.ToString());
            }
        }
        _Weapon.Unit.pressure -= 20;
        pressure += 20;
        if (Health <= 0)
        {
            Death();
        }

        return(true);
    }