示例#1
0
    public static void readSave(Save save)
    {
        //Clear existing objects
        ClearMatchThreeObjects();
        ClearAmmoObjects();
        DestroyCharacter();
        //Create Player
        playerInfo playerInfo = save.player;

        player = Instantiate(CharacterObject).GetComponent <MyCharacterController>();
        player.transform.position = playerInfo.position.GetPosition();
        Vector3 orientation = playerInfo.orientation.GetOrientation();

        player.my_camera.GetComponent <camMouseLook>().Look(orientation);
        player.SetCrouchState(playerInfo.crouched, true);
        player.health = playerInfo.health;
        GunController gunController = player.my_pickup.gunController;

        for (int i = 0; i < playerInfo.ammo.Length; ++i)
        {
            gunController.arsenal[i].gun.ammo      = playerInfo.ammo[i];
            gunController.arsenal[i].is_in_arsenal = playerInfo.inArse[i];
        }
        gunController.equip_gun((GunController.gun_type)playerInfo.equip);
        //Create Match Threes
        foreach (matchThreeObjectInfo obj in save.matchThreeObjectInfos)
        {
            GameObject       newObj   = Instantiate(matchThreeObjectTypes.types[obj.type], GameObject.Find(obj.room).transform);
            MatchThreeObject newObjM3 = newObj.GetComponent <MatchThreeObject>();
            newObj.name = obj.name;
            newObj.transform.position = obj.position.GetPosition();
            newObjM3.match3_group_id  = (MatchThreeObject.match3_group_id_names)obj.group;
            newObjM3.apply_color();
        }
        //Create Ammo Pickups
        foreach (ammoInfo obj in save.ammoInfos)
        {
            GameObject            newObj     = Instantiate(AmmoObject);
            PickupAmmoInteraction newObjAmmo = newObj.GetComponent <PickupAmmoInteraction>();
            newObj.name = obj.name;
            newObj.transform.position    = obj.position.GetPosition();
            newObj.transform.eulerAngles = obj.rotation.GetOrientation();
            newObjAmmo.gun    = (GunController.gun_type)obj.type;
            newObjAmmo.amount = obj.amount;
        }
        //Set Door Parameters
        foreach (doorInfo obj in save.doorInfos)
        {
            DoorInteraction door = GameObject.Find(obj.name).GetComponentInChildren <DoorInteraction>();
            door.twistLock(obj.locked);
            door.swingDoor(obj.open, false);
        }
        //Temporary code for setting references
        foreach (GameObject tutorial in tutorials)
        {
            tutorial.GetComponent <Tutorial>().GetUIComponents(player.gameObject);
        }
    }
 private void LockDoor(bool locked)
 {
     door.twistLock(locked);
 }