Example #1
0
    public static bool CheckCrossingCharacters(int time, Action action, Character character, Location targetLocation)
    {
        for (int i = 0, count = targetLocation.characters.Count; i < count; i++)
        {
            Character otherCharacter = targetLocation.characters[i];

            if (otherCharacter.CheckIdentity(character))
            {
                Action nextAction = otherCharacter.GetAction(time);

                if (nextAction != null)
                {
                    ActionEnter nextActionEnter = nextAction as ActionEnter;

                    if (nextActionEnter != null && nextActionEnter.targetLocation == character.GetCurrentLocation())
                    {
                        GameManager.paradox = new Paradox(action, character.GetName() + " met " + otherCharacter.GetName() + " between " + character.GetCurrentLocation().name + " and " + targetLocation.name + ", Paradox!");
                        return(false);
                    }
                }
            }
        }

        return(true);
    }
            public void It_should_trigger_the_Enter_action()
            {
                var triggered    = false;
                var actionUpdate = new ActionEnter((action) => triggered = true);

                actionUpdate.Enter();

                Assert.IsTrue(triggered);
            }
Example #3
0
    void DrawLocation(Location currentLocation)
    {
        GUI.Label(new Rect(posGUI.x, posGUI.y, fieldWidth, fieldHeight), "Enter : ");
        posGUI.y += fieldHeight;

        for (int i = 0; i < currentLocation.connectedLocations.Count; i++)
        {
            Location connectedLocation = currentLocation.connectedLocations[i];

            if (GUI.Button(new Rect(posGUI.x, posGUI.y, fieldWidth, fieldHeight), connectedLocation.name))
            {
                ActionEnter actionEnter = new ActionEnter(currentTime, connectedLocation);
                AddAction(actionEnter);
            }

            posGUI.y += fieldHeight;
        }

        posGUI.y += fieldHeight;
    }
Example #4
0
    public bool ItemInsideTimeMachine(int currentTime, Item item)
    {
        for (int i = 0, count = GameManager.Instance.characters.Count; i < count; i++)
        {
            Character character = GameManager.Instance.characters[i];

            bool insideTimeMachine = character.GetCurrentLocation() == GameManager.Instance.timeMachine;
            if (insideTimeMachine)
            {
                Action action = character.GetAction(currentTime);

                if (action != null)
                {
                    ActionEnter actionEnter = action as ActionEnter;

                    if (actionEnter != null)
                    {
                        insideTimeMachine = false;
                    }
                }
            }

            if (insideTimeMachine)
            {
                for (int j = 0, itemCount = character.inventory.Count; j < itemCount; j++)
                {
                    if (character.inventory[j] == item)
                    {
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
Example #5
0
    void Tick()
    {
        if (paradoxFound)
        {
            return;
        }

        //----// Character ticks //----// NPC actions for this tick added
        for (int i = 0, count = characters.Count; i < count; i++)
        {
            characters[i].Tick(currentTime);
        }

        //----// Perform and Verify actions //----//
        if (PerformActions() == false)
        {
            paradoxFound = true;
            return;
        }

        if (VerifyActions() == false)
        {
            paradoxFound = true;
            return;
        }

        //Time moves
        currentTime++;

        //Level Tick, Oven baking, Fire growing etc.
        if (currentLevel.Tick(currentTime, currentPlayer) == false)
        {
            paradoxFound = true;
            return;
        }

        //Check previous observations
        if (CheckObservations() == false)
        {
            paradoxFound = true;
            return;
        }

        //Make new observations
        for (int i = 0, count = characters.Count; i < count; i++)
        {
            Character character       = characters[i];
            Location  currentLocation = character.GetCurrentLocation();
            if (currentLocation != null && currentLocation != timeMachine)
            {
                character.MakeObservations(currentTime, currentLevel);
            }
        }

        //Add item timeline entries
        for (int i = 0, count = characters.Count; i < count; i++)
        {
            Character character     = characters[i];
            Action    currentAction = character.GetAction(currentTime - 1);

            if (character.GetCurrentLocation() != timeMachine || (currentAction != null && currentAction.GetType() == typeof(ActionEnter)))
            {
                for (int j = 0, itemCount = character.inventory.Count; j < itemCount; j++)
                {
                    Item item = character.inventory[j];
                    if (item != null && item.useTimeline)
                    {
                        item.age++;
                        itemTimeline.AddEntry(currentTime, item, currentPlayer, item.age, j, -1, character.GetCurrentLocation());
                        //						watchList.Add(watch.age);
                    }
                }
            }
        }

        Location[] locations = currentLevel.GetLocations();
        for (int i = 0, length = locations.Length; i < length; i++)
        {
            Location location = locations[i];
            for (int j = 0, itemCount = location.items.Count; j < itemCount; j++)
            {
                Item item = location.items[j];
                if (item != null && item.useTimeline)
                {
                    item.age++;
                    itemTimeline.AddEntry(currentTime, item, currentPlayer, item.age, -1, j, location);
                    //					watchList.Add(watch.age);
                }
            }
        }


        //Time travel

        for (int i = 0, characterCount = characters.Count; i < characterCount; i++)
        {
            Character character = characters[i];

            if (character != currentPlayer)
            {
                Action action = character.GetAction(currentTime - 1);
                if (action != null)
                {
                    ActionEnter actionEnter = action as ActionEnter;
                    if (actionEnter != null && actionEnter.targetLocation == timeMachine)
                    {
//						Debug.Log("Reached time tRavel of not currentPlayer");
//						character.SetCurrentLocation(null);

                        //TODO, ripple removed for now
                        //Character nextCharacter = characters[i+1];
                        //nextCharacter.initialInventory = Utils.CopyItemList(character.inventory);
                    }
                }
            }
        }

        {
            //ActionEnter actionEnter = currentPlayer.history[currentPlayer.history.Count-1] as ActionEnter;
            ActionEnter actionEnter = currentPlayer.GetAction(currentTime - 1) as ActionEnter;
            if (actionEnter != null && actionEnter.targetLocation == timeMachine)
            {
                TimeTravel();
            }
        }
    }