Пример #1
0
    private void loadScene()
    {
        SaveData data = SaveSystem.loadPlayer();

        if (data.level == SceneManager.GetActiveScene().buildIndex)
        {
            Vector3 position = new Vector3(data.playerPosition[0], data.playerPosition[1], data.playerPosition[2]);
            Player.transform.position = position;
            HealthAndShield healthAndShield = Player.GetComponent <HealthAndShield>();
            healthAndShield.health = data.health;
            healthAndShield.Shield = data.shield;
            GunPlaceHolderPlayer gunHolder = player.GetComponentInChildren <GunPlaceHolderPlayer>();
            gunHolder.activePrimary = data.primaryGunID;
            gun Primary = gunHolder.findWeaponByID(data.primaryGunID).GetComponent <gun>();
            Primary.ammoInBag         = data.PrimaryAmmoInBag;
            Primary.ammoInMag         = data.PrimaryAmmoInMag;
            gunHolder.activeSecondary = data.secondaryGunID;
            gun Secondary = gunHolder.findWeaponByID(data.secondaryGunID).GetComponent <gun>();
            Secondary.ammoInBag       = data.SecondaryAmmoInBag;
            Secondary.ammoInMag       = data.SecondaryAmmoInMag;
            gunHolder.grenadeCount[0] = data.GrenadeCount[0];
            gunHolder.grenadeCount[1] = data.GrenadeCount[1];
            gunHolder.grenadeCount[2] = data.GrenadeCount[2];
            gunHolder.switchWeapon();
            gunHolder.switchWeapon();
        }
    }
Пример #2
0
    public override void InRange()
    {
        HealthAndShield player = gameManager.player.GetComponent <HealthAndShield>();

        if (player.Shield < player.MaxShield)
        {
            player.recharge(0, shield);
        }
        Destroy(gameObject);
    }
Пример #3
0
    public static void SaveGame(GameObject player, GunPlaceHolderPlayer guns, HealthAndShield healthAndShield, int levelThis)
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        string          path            = Application.persistentDataPath + "/playerdata.rob";
        FileStream      stream          = new FileStream(path, FileMode.Create);
        SaveData        data            = new SaveData(player, guns, healthAndShield, levelThis);

        binaryFormatter.Serialize(stream, data);
        stream.Close();
    }
Пример #4
0
 void AICalculate()
 {
     if (Target != null)
     {
         HealthAndShield TargetShield = Target.GetComponent <HealthAndShield>();
         if (TargetShield.Shield >= TargetShield.MaxShield)
         {
             seekTarget();
         }
     }
     else
     {
         seekTarget();
     }
 }
Пример #5
0
 void seekTarget()
 {
     HealLineRenderer.SetPosition(1, EnergyPoint.position);
     //Debug.Log("seekTarget");
     Collider[] colliders = Physics.OverlapSphere(transform.position, detectRange);
     foreach (Collider collider in colliders)
     {
         if (collider.tag == "Enemy")
         {
             HealthAndShield colHealthAndShield = collider.gameObject.GetComponent <HealthAndShield>();
             if (colHealthAndShield.Shield < colHealthAndShield.MaxShield && colHealthAndShield.IsAlive)
             {
                 Target = colHealthAndShield.gameObject;
             }
         }
     }
 }
Пример #6
0
 IEnumerator Damage()
 {
     while (true)
     {
         Collider[] colliders = Physics.OverlapSphere(transform.position, range);
         foreach (Collider col in colliders)
         {
             if (col.CompareTag("Player") || col.CompareTag("Enemy") || col.CompareTag("Destroyable"))
             {
                 HealthAndShield VictimHealth = col.gameObject.GetComponent <HealthAndShield>();
                 float           distance     = Vector3.Distance(col.gameObject.transform.position, transform.position);
                 if (distance < range)
                 {
                     VictimHealth.damage(damagePerClick, grenadeHealthDamageRatio, grenadeShieldDamageRatio);
                 }
             }
         }
         yield return(new WaitForSeconds(ClickInterval));
     }
 }
Пример #7
0
 void GrenadeDamage()
 {
     Collider [] colliders = Physics.OverlapSphere(transform.position, range);
     foreach (Collider col in colliders)
     {
         Rigidbody victimRB = col.gameObject.GetComponent <Rigidbody> ();
         if (victimRB != null && victimRB.gameObject != gameObject)
         {
             Force(victimRB);
         }
         if (col.CompareTag("Player") || col.CompareTag("Enemy") || col.CompareTag("Destroyable"))
         {
             HealthAndShield VictimHealth = col.gameObject.GetComponent <HealthAndShield>();
             float           distance     = Vector3.Distance(col.gameObject.transform.position, transform.position);
             if (distance < range)
             {
                 VictimHealth.damage(damage - (distance / range) * damage, grenadeHealthDamageRatio, grenadeShieldDamageRatio);
             }
         }
     }
 }
Пример #8
0
    public SaveData(GameObject player, GunPlaceHolderPlayer guns, HealthAndShield healthAndShield, int levelThis)
    {
        level             = levelThis;
        playerPosition    = new float[3];
        playerPosition[0] = player.transform.position.x;
        playerPosition[1] = player.transform.position.y;
        playerPosition[2] = player.transform.position.z;
        primaryGunID      = guns.activePrimary;
        GrenadeCount      = new int[3];
        secondaryGunID    = guns.activeSecondary;
        GrenadeCount[0]   = guns.grenadeCount[0];
        GrenadeCount[1]   = guns.grenadeCount[1];
        GrenadeCount[2]   = guns.grenadeCount[2];
        health            = healthAndShield.health;
        shield            = healthAndShield.Shield;
        gun PrimaryGun = guns.findWeaponByID(guns.activePrimary).GetComponent <gun>();

        PrimaryAmmoInBag = PrimaryGun.ammoInBag;
        PrimaryAmmoInMag = PrimaryGun.ammoInMag;
        gun SecondaryGun = guns.findWeaponByID(guns.activeSecondary).GetComponent <gun>();

        SecondaryAmmoInBag = SecondaryGun.ammoInBag;
        SecondaryAmmoInMag = SecondaryGun.ammoInMag;
    }
Пример #9
0
 // Start is called before the first frame update
 void Start()
 {
     player = gameManager.player;
     gunPlaceHolderReference  = player.GetComponentInChildren <GunPlaceHolderPlayer>();
     healthAndShieldReference = player.GetComponent <HealthAndShield>();
 }
Пример #10
0
 private void Start()
 {
     playerHealthAndShield = gameManager.player.GetComponent <HealthAndShield>();
 }