Exemplo n.º 1
0
 private void HandleAutosave(GameElementManager elementManager)
 {
     if (elementManager.GameProperties.IsCheckpointOn && elementManager.CurrentRoom.IsCheckPoint && !elementManager.CurrentRoom.IsVisited)
     {
         gameSaver.AutoSave();
     }
 }
Exemplo n.º 2
0
 public GEPropertyChecker(GameElementManager elementManager, string refId, PropertyConditionType conditionType, double valueToCheck)
 {
     this.elementManager = elementManager;
     this.refId          = refId;
     this.conditionType  = conditionType;
     this.valueToCheck   = valueToCheck;
 }
Exemplo n.º 3
0
        public void Execute(GameElementManager elementManager)
        {
            GEProperty property = elementManager.GetProperty(refId);

            if (property == null)
            {
                ObjectManager.Logger.LogWarn("There is no property element with the given id, however an action is reffering it! The given id: " + refId);
            }
            switch (changeType)
            {
            case PropertyChangeType.SET:
            {
                property.Value = this.value;
                break;
            }

            case PropertyChangeType.INC:
            {
                property.Value += this.value;
                break;
            }

            case PropertyChangeType.DEC:
            {
                property.Value -= this.value;
                break;
            }
            }
        }
Exemplo n.º 4
0
    public static string StoreAutoSavedGameGEM(string dirName, GameElementManager gem)
    {
        string savedGameName = AutoSaveName + GetCurrentTime();

        StoreGEM(dirName, savedGameName, gem, true);
        ManageAutoSavedGames(dirName);
        return(savedGameName);
    }
Exemplo n.º 5
0
 public void Unequip(GameElementManager elementManager)
 {
     if (equipable && isEquipped)
     {
         elementManager.Player.Items.Remove(id);
         isEquipped = false;
     }
 }
Exemplo n.º 6
0
 public void Equip(GameElementManager elementManager)
 {
     if (equipable && !isEquipped)
     {
         elementManager.Player.Items.Add(id, this);
         isEquipped = true;
     }
 }
Exemplo n.º 7
0
 public GEAction(GameElementManager elementManager, GEText responseText, List <GEActivation> activations, List <GEPropertySetter> propertySetters, GESaveAction saveAction, int useInterval)
 {
     this.elementManager  = elementManager;
     this.responseText    = responseText;
     this.activations     = activations;
     this.propertySetters = propertySetters;
     this.useInterval     = useInterval;
     this.saveAction      = saveAction;
 }
Exemplo n.º 8
0
    private void HandleBackgroundImage(GameElementManager elementManager)
    {
        string imgName = elementManager.CurrentRoom.ImgPath;

        OnBcgImageLoadFinished += new EventHandler <ImgLoaderArgs>(LoadBcgImage);
        Thread loadingThread = new Thread(() => StartLoadBcgImage(elementManager.GameStorageName, imgName, OnBcgImageLoadFinished));

        loadingThread.Start();
    }
    // Use this for initialization
    void Start()
    {
        logger = ObjectManager.Logger;
        LoadTexts();
        InitLangMenu();
        bcgImageScript = GetComponent <BcgImage>();
        GameElementManager gem           = ObjectManager.CurrentGEM;
        Thread             loadingThread = new Thread(() => StartLoadBcgImage(gem.GameStorageName, gem.GameProperties.MenuImgSrc));

        loadingThread.Start();
    }
Exemplo n.º 10
0
 private void ManageAfterSave(string saveName, GameElementManager gem)
 {
     isSaveInAction = false;
     isSaveFinished = true;
     lock (syncLock)
     {
         if (!gem.savedGameNames.Contains(saveName))
         {
             gem.savedGameNames.Add(saveName);
         }
     }
 }
Exemplo n.º 11
0
            public void Execute(GameElementManager elementManager)
            {
                GEItem item = elementManager.GetItem(refId);

                if (isForEquip)
                {
                    item.Equip(elementManager);
                }
                else
                {
                    item.Unequip(elementManager);
                }
            }
Exemplo n.º 12
0
    //private LayoutElement itemLayoutMemo;

    //public abstract List<GameElement> GetDataList();

    public virtual void Start()
    {
        gameElementManager = GetGameElementManager();//gameElementManagerObject.GetComponent<GameElementManager>();

        if (gameElementManager != null)
        {
            //eleList = GetEleList();

            gameElementManager.Attach(this); //register subject

            InitListItem();
        }
    }
Exemplo n.º 13
0
 public void OpenMenu(GameElementManager gem, bool fromParent)
 {
     if (elementManager == null || elementManager != gem)
     {
         InitMenu(gem);
     }
     else
     {
         RefreshNames();
     }
     inputField.text = "";
     menuController.OpenMenu(fromParent);
 }
Exemplo n.º 14
0
    public void HeadBackToGameMenu()
    {
        List <string> savedNames = ObjectManager.CurrentGEM.savedGameNames;

        ObjectManager.CurrentGEM = GameElementManager.GetInitialGEM();
        ObjectManager.CurrentGEM.savedGameNames = savedNames;
#if UNITY_ANDROID && !UNITY_EDITOR
        SceneManager.LoadScene("GameMenu_Android");
#endif
#if UNITY_STANDALONE || UNITY_EDITOR
        SceneManager.LoadScene("GameMenu_Standalone");
#endif
    }
Exemplo n.º 15
0
    public void LoadCurrentRoom()
    {
        GameElementManager elementManager = ObjectManager.CurrentGEM;

        desctiptionScript.SetRoomName(elementManager.CurrentRoom.NameText.GetText());
        desctiptionScript.SetDescriptionText(elementManager.CurrentRoom.DescText.GetText());
        menuController.LoadRoom(elementManager.CurrentRoom);

        HandleAutosave(elementManager);
        HandleBackgroundImage(elementManager);

        elementManager.CurrentRoom.IsVisited = true;
    }
Exemplo n.º 16
0
 private void InitMenu(GameElementManager gem)
 {
     elementManager = gem;
     menuController = this.gameObject.GetComponent <ModalMenuController>();
     saveButton.onClick.AddListener(SaveGame);
     saveButton.GetComponentInChildren <Text>().text = LabelUtility.Instance.GetLabel(LabelNames.SAVE);
     menuController.SetMenuName(LabelUtility.Instance.GetLabel(LabelNames.SAVE));
     inputPlaceholder.text = LabelUtility.Instance.GetLabel(LabelNames.SAVENAME);
     foreach (string savedGameName in ObjectManager.CurrentGEM.savedGameNames)
     {
         menuController.AddButton(savedGameName, delegate { SetSaveName(savedGameName); });
     }
 }
Exemplo n.º 17
0
    public static void StartMainGame()
    {
        players              = new List <GameObject>();
        leprechauns          = new List <GameObject>();
        drinks               = new List <GameObject>();
        environmentGlasses   = new List <GameObject>();
        environmentPaintings = new List <GameObject>();

        lepGOlepScript = new Dictionary <GameObject, string>();

        WorldObject  = GameObject.FindGameObjectWithTag("Global").AddComponent <World>();
        GameElements = GameObject.FindGameObjectWithTag("Global").AddComponent <GameElementManager>();

        LATE_START = true;
    }
    public static void StartMainGame()
    {
        players = new List<GameObject>();
        leprechauns = new List<GameObject>();
        drinks = new List<GameObject>();
        environmentGlasses = new List<GameObject>();
        environmentPaintings = new List<GameObject>();

        lepGOlepScript = new Dictionary<GameObject, string>();

        WorldObject = GameObject.FindGameObjectWithTag("Global").AddComponent<World>();
        GameElements = GameObject.FindGameObjectWithTag("Global").AddComponent<GameElementManager>();

        LATE_START = true;
    }
Exemplo n.º 19
0
        public void Execute(GameElementManager elementManager)
        {
            IActivatable activatable = elementManager.GetActivatableGameElement(refId);

            if (activatable == null)
            {
                ObjectManager.Logger.LogWarn("There is no activatable element with the given id, however an action is reffering it! The given id: " + refId);
            }
            if (valueToSet == null)
            {
                activatable.SetActive(!activatable.IsActive());
            }
            else
            {
                activatable.SetActive((bool)valueToSet);
            }
        }
Exemplo n.º 20
0
    public static void StoreGEM(string dirName, string fileName, GameElementManager gem, bool isSavedGame = false)
    {
        FileStream      file = null;
        BinaryFormatter bf   = new BinaryFormatter();
        string          filePath;

        if (isSavedGame)
        {
            filePath = BuildPath(StoredGamesPath, dirName, SavedGamesStore, fileName + Extension);
        }
        else
        {
            filePath = BuildPath(StoredGamesPath, dirName, fileName + Extension);
        }
        using (file = File.Open(filePath, FileMode.Create))
        {
            bf.Serialize(file, gem);
        }
    }
    public void ProcessMultipleGameDescriptor(List <GameDescriptor> gameDescriptors, Dictionary <string, MemoryStream> images)
    {
        if (gameDescriptors.Count == 0)
        {
            return;
        }

        GameDescriptor root = GetRootDescriptor(gameDescriptors);

        if (root == null)
        {
            root = gameDescriptors[0];
        }
        string gameName        = root.gameName;
        string version         = root.version ?? "";
        string gameStorageName = gameName + "_" + version;

        if (PersistanceHelper.CheckGameDirectory(gameStorageName))
        {
            SetExistingGemAsCurrent(gameStorageName);
            return;
        }

        elementManager         = new GameElementManager(gameStorageName);
        elementManager.DefLang = root.GameProperties.defaultLang;
        PersistanceHelper.CreateStorage(gameStorageName);
        PersistanceHelper.StoreImages(gameStorageName, images);
        foreach (GameDescriptor descripor in gameDescriptors)
        {
            ProcessGameDescriptor(descripor);
        }
        if (OnReferenceProcessing != null)
        {
            OnReferenceProcessing(null, EventArgs.Empty);
        }
        elementManager.SetFirstRoom();
        PersistanceHelper.StoreInitialGEM(gameStorageName, elementManager);
        ObjectManager.CurrentGEM = elementManager;
    }
Exemplo n.º 22
0
    public static GameElementManager GetGEM(string dirName, string fileName, bool isSavedGame = false)
    {
        GameElementManager ret = null;
        string             filePath;

        if (isSavedGame)
        {
            filePath = BuildPath(StoredGamesPath, dirName, SavedGamesStore, fileName + Extension);
        }
        else
        {
            filePath = BuildPath(StoredGamesPath, dirName, fileName + Extension);
        }
        if (File.Exists(filePath))
        {
            using (FileStream file = File.Open(filePath, FileMode.Open))
            {
                BinaryFormatter bf = new BinaryFormatter();
                file.Position = 0;
                ret           = (GameElementManager)bf.Deserialize(file);
            }
        }
        return(ret);
    }
Exemplo n.º 23
0
 public GEEquippedChecker(GameElementManager elementManager, string refId, bool valueToCheck = true)
 {
     this.elementManager = elementManager;
     this.refId          = refId;
     this.valueToCheck   = valueToCheck;
 }
Exemplo n.º 24
0
 public GEItemAction(GameElementManager elementManager, GEText responseText, List <GEActivation> activations, List <GEPropertySetter> propertySetters, GESaveAction saveAction, List <GEEquipItem> equipItems, int useInterval) : base(elementManager, responseText, activations, propertySetters, saveAction, useInterval)
 {
     this.equipItems = equipItems;
 }
Exemplo n.º 25
0
 public MIEquip(GEItem geItem, MenuItemBundle parentBundle) : base(LabelUtility.Instance.GetLabel(LabelNames.PICKUP), parentBundle)
 {
     elementManager = ObjectManager.CurrentGEM;
     this.geItem    = geItem;
     description    = Description.GetInstance();
 }
Exemplo n.º 26
0
    private void StartSaveWithTimetag(string gameName, string sourceName, GameElementManager gem)
    {
        string saveName = PersistanceHelper.StoreSaveStationSavedGameGEM(gameName, sourceName, gem);

        ManageAfterSave(saveName, gem);
    }
Exemplo n.º 27
0
 public static void StoreSavedGameGEM(string dirName, string fileName, GameElementManager gem)
 {
     StoreGEM(dirName, fileName, gem, true);
 }
Exemplo n.º 28
0
 public GEActivationChecker(GameElementManager elementManager, string refId, bool valueToCheck)
 {
     this.elementManager = elementManager;
     this.refId          = refId;
     this.valueToCheck   = valueToCheck;
 }
Exemplo n.º 29
0
 public static void StoreInitialGEM(string dirName, GameElementManager gem)
 {
     StoreGEM(dirName, InitialGemName, gem);
 }
Exemplo n.º 30
0
    public static string StoreSaveStationSavedGameGEM(string dirName, string saveStationId, GameElementManager gem)
    {
        string saveName = saveStationId + "_" + GetCurrentTime();

        StoreGEM(dirName, saveName, gem, true);
        return(saveName);
    }
Exemplo n.º 31
0
 private void StartSave(string gameName, string saveName, GameElementManager gem)
 {
     PersistanceHelper.StoreSavedGameGEM(gameName, saveName, gem);
     ManageAfterSave(saveName, gem);
 }