コード例 #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
ファイル: SaveSystem.cs プロジェクト: AnujStha/RobocalypseC
    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();
    }
コード例 #3
0
    public override void InRange()
    {
        int type = id % 100;

        base.interact();
        GunPlaceHolderPlayer holder = gameManager.player.GetComponentInChildren <GunPlaceHolderPlayer>();

        holder.grenadeCount[type] += count;
        Destroy(gameObject);
    }
コード例 #4
0
    public override void InRange()
    {
        base.InRange();
        GunPlaceHolderPlayer holder = gameManager.player.GetComponentInChildren <GunPlaceHolderPlayer>();

        if (holder.activePrimary == id)
        {
            holder.findWeaponByID(id).GetComponent <gun>().ammoInBag += ammo;
            Destroy(gameObject);
        }
    }
コード例 #5
0
    public override void interact()
    {
        base.interact();
        GunPlaceHolderPlayer holder = gameManager.player.GetComponentInChildren <GunPlaceHolderPlayer>();
        GameObject           c      = Instantiate(creator, transform.position, transform.rotation);
        pupCreater           create = c.GetComponent <pupCreater>();
        bool replacing;

        if (holder.activePrimary == id)
        {
            replacing = false;
        }
        else
        {
            replacing = true;
            /////
            gun g = holder.findWeaponByID(holder.activePrimary).GetComponent <gun>();

            create.id   = g.id;
            create.ammo = g.ammoInBag + g.ammoInMag;
            g.ammoInMag = 0;
        }
        holder.activePrimary = id;
        if (holder.holdingPrimary)
        {
            holder.switchWeapon();
            holder.switchWeapon();
        }
        else
        {
            holder.switchWeapon();
        }
        if (replacing)
        {
            holder.ActiveGun.GetComponent <gun>().ammoInBag = ammo;
            create.Create();
        }
        else
        {
            holder.ActiveGun.GetComponent <gun>().ammoInBag += ammo;
        }
        Destroy(gameObject);
    }
コード例 #6
0
ファイル: SaveData.cs プロジェクト: AnujStha/RobocalypseC
    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;
    }
コード例 #7
0
ファイル: IngameInfo.cs プロジェクト: AnujStha/RobocalypseC
 // Start is called before the first frame update
 void Start()
 {
     player = gameManager.player;
     gunPlaceHolderReference  = player.GetComponentInChildren <GunPlaceHolderPlayer>();
     healthAndShieldReference = player.GetComponent <HealthAndShield>();
 }