Ejemplo n.º 1
0
 //function for dog switching
 public void switchDog(int number)
 {
     timeWhenChewableWearsOff = Time.time;
     hpSaving.Raise(currentHP);
     switching.Raise(number);
     Debug.Log("dog switch events called");
 }
Ejemplo n.º 2
0
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.IsName("Motion Matching"))
     {
         lerpEvent.Raise(0);
     }
 }
Ejemplo n.º 3
0
 public override void AddGold(RunTimeTroopData troopData)
 {
     if (troopData.isEnemy)
     {
         AddGold(troopData.valDropMoney);
         playerGoldChangeEvent.Raise(currentGold);
     }
 }
Ejemplo n.º 4
0
    private void Start()
    {
        int buildIndex = SceneManager.GetActiveScene().buildIndex;

        if (buildIndex == 1 || buildIndex == 2 || buildIndex == 3)
        {
            preGameTransitionIndex.Raise(2 * buildIndex - 1);
        }
    }
Ejemplo n.º 5
0
        private void TickUpdated(float tick)
        {
            int convertedTick = Mathf.CeilToInt(tick);

            if (convertedTick != _currentCount)
            {
                _currentCount = convertedTick;
                countdownTickEvent?.Raise(_currentCount);
            }
        }
Ejemplo n.º 6
0
    // Start is called before the first frame update
    public override void Start()
    {
        base.Start();

        //Enable the healthbar
        enableHealthBarEvent.Raise();

        //Set the max value on the healthbar
        setMaxHealthEvent.Raise(maxHealth.Value);

        //Update the healthbar immediately
        updateHealthBarEvent.Raise(health);
    }
Ejemplo n.º 7
0
    public void StartLevel()
    {
        //Set up the player UI
        setMaxHealthEvent.Raise((int)maxHealth.Value);
        setMaxManaEvent.Raise((int)maxMana.Value);
        setManaEvent.Raise(mana);
        setHealthEvent.Raise(health);
        setScoreEvent.Raise(score);

        //Link the player inventory to any relevant components
        inventoryEvent.Raise(inventory);

        //Set up the reference to the camera
        setCameraRefEvent.Raise(cameraTarget);
    }
Ejemplo n.º 8
0
 private void OnDisable()
 {
     if (eventAliveEnemies != null)
     {
         eventAliveEnemies.Raise(-1);
     }
 }
Ejemplo n.º 9
0
        public override void OnInspectorGUI()
        {
            IntEvent script = (IntEvent)target;

            //Event Description
            GUILayout.BeginVertical();
            EditorGUILayout.LabelField("Event Description", EditorStyles.centeredGreyMiniLabel);
            EditorStyles.textField.wordWrap = true;
            script.EventDescription         = EditorGUILayout.TextArea(script.EventDescription, GUILayout.MinHeight(100));
            GUILayout.EndVertical();

            //Test Event Button
            GUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.LabelField("Test Event", EditorStyles.centeredGreyMiniLabel);
            value = EditorGUILayout.IntField("Value ", value);

            if (GUILayout.Button("Raise"))
            {
                if (Application.isPlaying)
                {
                    script.Raise(value);
                }
            }
            GUILayout.EndVertical();
        }
Ejemplo n.º 10
0
        private void doTick()
        {
            data.Step++;

            // Update data
            if (data.Step < ClockSteps)
            {
                GameTickEvent.Raise(data.Step);
            }
            else
            {
                data.Step = 0;
                data.Date.IncrementDay();
                GameTickEvent.Raise(data.Step);
                GameDayEvent.Raise(data.Date);
            }
        }
Ejemplo n.º 11
0
        private void TriggerEvent()
        {
            _currentEvent = RandomizedEvents[Random.Range(0, RandomizedEvents.Count)];
            int eventDuration = Random.Range(MinDuration, MaxDuration);

            _currentEvent.Raise(eventDuration);
            Debug.Log("Event Triggered : " + _currentEvent.name + " for " + eventDuration + " seconds");
        }
Ejemplo n.º 12
0
 public void StartGame()
 {
     if (!HasGameStarted)
     {
         HasGameStarted.Value = true;
         OnStartGame.Raise(CooldownBeforeStart);
     }
 }
Ejemplo n.º 13
0
        public void AddCurrentHealth(int amount)
        {
            _currentHealth.Value += amount;

            if (_currentHealth < 0)
            {
                _currentHealth.Value = 0;
            }

            if (_currentHealth >= _maxHealth)
            {
                _currentHealth.Value          = _maxHealth.Value;
                _creatureManager.CurrentState = CreatureState.OnComeBack;
            }

            onHealthUpdate?.Raise(_currentHealth);
        }
Ejemplo n.º 14
0
 // Start is called before the first frame update
 public virtual void Start()
 {
     //Set health to maxHealth
     health = (int)maxHealth.Value;
     //Find the player in scene
     playerTarget = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>();
     //Set the nav agent target to the player
     agent.destination = playerTarget.transform.position;
     //Set the speed of the agent
     agent.speed = speed.Value;
     //Get reference to the animator component
     anim = GetComponent <Animator>();
     //Get reference to collider
     col = GetComponent <Collider>();
     //Increase the number of enemies in the scene by one
     enemyCountEvent.Raise(1);
 }
Ejemplo n.º 15
0
        public void UpdateCurrentHealth(int health)
        {
            //Check if dead or not
            if (health <= 0)
            {
                Die();
            }
            else
            {
                _currentHealth = health;

                if (onHealthUpdate != null)
                {
                    onHealthUpdate.Raise(_currentHealth);
                }
            }
        }
Ejemplo n.º 16
0
 public void UpdateCurrentHealth(int health)
 {
     _currentHealth.Value = health;
     if (onHealthUpdate != null)
     {
         onHealthUpdate.Raise(_currentHealth);
     }
 }
    public void Update()
    {
        if (hasTimerRunOut)
        {
            return;
        }
        if (timer > maxTime)
        {
            Debug.Log("Timer ran out after " + timer + " seconds");
            hasTimerRunOut = true;

            //Demonstration of using an intEvent to tell another script that a timer has run out and pass a value:
            intEventTest.Raise((int)timer);
            return;
        }
        timer += Time.deltaTime;
    }
Ejemplo n.º 18
0
    public ZoeRecolor defaultZoeRecolor; //The one to select if no other skin has been selected.

    public void SetCurrentZoeRecolor(int zoeRecolorIndex)
    {
        //Call "ChangeZoeRecolor" event that is listened for by skinswapper.cs on the zoe-CGI nested prefab. (Only if there is a recolor with the corresponding index though)
        if (allZoeRecolors[zoeRecolorIndex] != null)
        {
            currentZoeRecolor = allZoeRecolors[zoeRecolorIndex];
            changeZoeRecolor.Raise(zoeRecolorIndex);
        }
    }
Ejemplo n.º 19
0
 public void Add()
 {
     if (numberOfKeywords.value >= 5)
     {
         onMaxKeywords.Invoke();
         return;
     }
     keywordAdd.Raise(keywordIndex);
 }
Ejemplo n.º 20
0
    // -= Events =-

    public void OnStairsInteractEventReceived(int input)
    {
        inputEnabled.value = false;

        // an input of 0 means that this is a staircase going down
        if (input == 0)
        {
            entityManager.UpdateEntitiesInDungeon(dungeon, entitiesParent);
            floorsAbove.Push(dungeon);
            Destroy(dungeonParent);

            // load dungeon if there are floors below, else generate new floor
            if (floorsBelow.Count > 0)
            {
                dungeon = floorsBelow.Pop();
            }
            else
            {
                dungeon = new Dungeon(width / 3, height / 3);
                entityManager.PopulateDungeon(dungeon, 5);
            }

            InstantiateDungeon(dungeon);
            InstantiateEntitiesInDungeon(dungeon);
            playerInstance.GetComponent <PlayerPhysics>().Teleport(
                new Vector3(dungeon.getStartCoordX(), dungeon.getStartCoordY(), playerInstance.transform.position.z));
        }

        // an input of 1 means that this is a staircase going up
        else if (input == 1)
        {
            entityManager.UpdateEntitiesInDungeon(dungeon, entitiesParent);
            floorsBelow.Push(dungeon);
            Destroy(dungeonParent);

            if (floorsAbove.Count > 0)
            {
                dungeon = floorsAbove.Pop();
            }
            else
            {
                dungeon = new Dungeon(width / 3, height / 3);
                entityManager.PopulateDungeon(dungeon, 5);
            }

            InstantiateDungeon(dungeon);
            InstantiateEntitiesInDungeon(dungeon);
            playerInstance.GetComponent <PlayerPhysics>().Teleport(
                new Vector3(dungeon.getEndCoordX(), dungeon.getEndCoordY(), playerInstance.transform.position.z));
        }

        currentFloor.value = floorsAbove.Count + 1;
        onFloorChange.Raise(currentFloor.value);

        inputEnabled.value = true;
    }
Ejemplo n.º 21
0
        private void OnParticleTrigger()
        {
            List <ParticleSystem.Particle> enter = new List <ParticleSystem.Particle>();
            int numEnter = _toxicParticles.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);

            if (numEnter > 0)
            {
                PlayerDeath.Raise(_playerId);
            }
        }
Ejemplo n.º 22
0
        private void FixedUpdate()
        {
            if (!_paused)
            {
                LeftCharInfo.Move(RightCharInfo, _moveSpeed, _walkForwardForce);
                RightCharInfo.Move(LeftCharInfo, _moveSpeed, _walkForwardForce);

                if (LeftCharInfo.Go.transform.position.y < -60f)
                {
                    PlayerDeathEvent.Raise(1);
                    CharacterDeath(1);
                }
                else if (RightCharInfo.Go.transform.position.y < -60f)
                {
                    PlayerDeathEvent.Raise(2);
                    CharacterDeath(2);
                }
            }
        }
Ejemplo n.º 23
0
 private void Update()
 {
     for (int i = 0; i < numberKeys.Length; i++)
     {
         if (Input.GetKeyDown(numberKeys[i]))
         {
             onNumberKeyPressed.Raise(i);
         }
     }
 }
Ejemplo n.º 24
0
    private void PickupObject()
    {
        //Player the pickup event
        pickupEvent.Raise(pickupValue);

        //Play the pickup sound
        playSFXEvent.Raise(pickupSound);

        //Destroy the object
        Destroy(this.gameObject);
    }
Ejemplo n.º 25
0
    public override void UseItem()
    {
        //Raise the restore item event
        restoreEvent.Raise(recoverValue);

        //Call event to use item
        useItemEvent.Raise(new ItemSlot(this, 1));

        //Play the item use sound
        playUseSoundEvent.Raise(useItemSound);
    }
Ejemplo n.º 26
0
    IEnumerator LevelResetCoroutine()
    {
        var loadOperation = SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex);

        while (!loadOperation.isDone)
        {
            yield return(null);
        }

        levelFinishedEvent.Raise(currentLevelId - 1);
    }
Ejemplo n.º 27
0
 private void Update()
 {
     if (CurrentTime.Value <= CooldownBeforeEnd && !_isGameEnding)
     {
         OnEndGame.Raise(CooldownBeforeEnd);
         _isGameEnding = true;
     }
     else
     {
         ComputeEventProbability();
     }
 }
    //When a snake gets a time travel block, it will send an event to time
    //travel handeler, in order to record the grid state.
    public void OnSnakeGetTimeTravelBlock(GameObject snakeGO)
    {
        Snake snake = snakeGO.GetComponent <Snake>();

        RemoveOldTimeTravelData(snake);

        TimeTravelData newTimeTravelData = new TimeTravelData(timeTravelId, snake);

        snakesTimeTravelData.Add(newTimeTravelData);

        OnRequestReferences.Raise(timeTravelId);
        timeTravelId++;
    }
Ejemplo n.º 29
0
        /// <summary>
        /// Hires the specified employee.
        /// If the employee does not exist in the employeesForHire List this method will do nothing;
        /// </summary>
        /// <param name="empData">The employee to hire.</param>
        public void HireEmployee(EmployeeData empData, GameObject employeeForHireGui)
        {
            if (!data.employeesForHire.Contains(empData))
            {
                return;
            }

            RemoveEmployeeForHire(empData);
            AddHiredEmployee(empData);
            if (HiredEmployees >= MaxNumberOfHiredEmployees)
            {
                data.employeesForHire.ForEach(emp =>
                                              EmployeeToGuiMap[emp].GetComponent <HireableEmployeeUiBuilder>().DisableHireButton(true));
            }
            EmployeesNumChangedEvent.Raise(data.hiredEmployees.Count);

            if (!data.FirstEmployeeHired)
            {
                data.FirstEmployeeHired = true;
                FirstEmployeeHired.Raise(GetEmployee(empData));
            }
        }
Ejemplo n.º 30
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUI.enabled = Application.isPlaying;

        IntEvent e = target as IntEvent;

        if (GUILayout.Button("Raise"))
        {
            e.Raise(value);
        }
    }