Пример #1
0
 private void HandleCurrentScoreEvent()
 {
     if (_isSleeping && _scoreCountingEvent != null)
     {
         _scoreCountingEvent.Invoke(1);
     }
 }
Пример #2
0
    // Start is called before the first frame update
    private void Start()
    {
        onStartEvent?.Invoke();
        onMyIntEvent?.Invoke(1);                                    // passing parameter into event
        onMyEvent?.Invoke(2);

        RemoveListeners();

        onStartEvent?.Invoke();
        onMyIntEvent?.Invoke(1);
        onMyEvent?.Invoke(2);
    }
Пример #3
0
    private void MoveToTarget(int x_target, int y_target)
    {
        CalculateMoveList(x_target, y_target);
        int prev_x = 0, prev_y = 0;
        var moveList = StaticVars.backtrackMinSol;

        foreach (var item in moveList)
        {
            if (StaticVars.hasReachTarget)
            {
                return;
            }
            prev_x = StaticVars.curRow;
            prev_y = StaticVars.curCol;
            if (item.Item1 > StaticVars.curRow && item.Item2 == StaticVars.curCol)
            {
                //move Down
                UpdateCurrentLocation(item.Item1, item.Item2);
                OnLocationChanged.Invoke(2);
                CheckForObstacle(prev_x, prev_y);
                continue;
            }
            if (item.Item1 < StaticVars.curRow && item.Item2 == StaticVars.curCol)
            {
                //move Up
                UpdateCurrentLocation(item.Item1, item.Item2);
                OnLocationChanged.Invoke(0);
                CheckForObstacle(prev_x, prev_y);
                continue;
            }
            if (item.Item1 == StaticVars.curRow && item.Item2 > StaticVars.curCol)
            {
                //move Right
                UpdateCurrentLocation(item.Item1, item.Item2);
                OnLocationChanged.Invoke(1);
                CheckForObstacle(prev_x, prev_y);
                continue;
            }
            if (item.Item1 == StaticVars.curRow && item.Item2 < StaticVars.curCol)
            {
                //move Left
                UpdateCurrentLocation(item.Item1, item.Item2);
                OnLocationChanged.Invoke(3);
                CheckForObstacle(prev_x, prev_y);
                continue;
            }
        }
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            myEvent.Invoke();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            // エディタ上でイベントを登録した場合、ここで登録した引数は無視される。
            myIntEvent.Invoke(123);
        }

        // スクリプトだけでイベントを加え、さらに、実行後自らを削除してみる例
        // https://answers.unity.com/questions/1492047/unityactionunityevent-remove-listener-from-within.html
        if (Input.GetKeyDown(KeyCode.T))
        {
            //SetEventFromCode(() => Debug.Log("Invoked Medthod whidh is added from code"));
            UnityAction myAction = null;
            myAction = new UnityAction(() =>
            {
                Debug.Log("Invoked Medthod whidh is added from code");
                myEvent.RemoveListener(myAction);
            });
            SetEventFromCode(myAction);
        }
    }
Пример #5
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.name == "BottomWall")
     {
         collideBottom.Invoke(-1);
     }
 }
Пример #6
0
 public void PlayerKill(int score)
 {
     if (playerKill != null)
     {
         playerKill.Invoke(score);
     }
 }
Пример #7
0
 void Update()
 {
     if (Input.anyKeyDown && m_MyEvent != null)
     {
         m_MyEvent.Invoke(5);
     }
 }
Пример #8
0
 void Punch(Vector3 position)
 {
     if (invulnerable)
     {
         return;
     }
     if (guard)
     {
         stamina -= 10;
         whenLoseStamina.Invoke(stamina.ToString());
         return;
     }
     print("Auch...");
     if (!anim.GetCurrentAnimatorStateInfo(0).IsName("FALL_Player"))
     {
         invulnerable = true;
         StartCoroutine(SetVulnerable());
         anim.SetTrigger("getPunch");
         position.y = transform.position.y;
         rb.AddForce((transform.position - position) * force, ForceMode2D.Impulse);
         lives--;
         whenLoseLife.Invoke(lives.ToString());
         if (lives < 0)
         {
             whenDie.Invoke();
         }
     }
 }
    void ApplyTouristDebuf(touristSize touristSize)
    {
        float modifier = 1.0f;

        foreach (TouristModifier touristeModifier in m_modifier)
        {
            if (touristeModifier.touristeType == touristSize.m_Type)
            {
                modifier = touristeModifier.modifier;
            }
        }

        if (touristSize.BreakDownValue > 0)
        {
            CurrentBreakDownValue -= (int)((float)touristSize.BreakDownValue * modifier);
            BreakDownApply.Invoke(CurrentBreakDownValue);
            BreakText.text = "Break : " + CurrentBreakDownValue;
            if (CurrentBreakDownValue <= 0)
            {
                //gameOver
                GameStateManager.setGameState(GameState.GameOver);
                SceneManager.LoadSceneAsync(touristSize.GameOverSceneName);
            }
        }
    }
Пример #10
0
 public void PlayerLifeLost(int currentLives)
 {
     Debug.Log("Player loses a life and now has " + currentLives + " lives");
     if (lifeLostEvents != null)
     {
         lifeLostEvents.Invoke(currentLives);
     }
 }
Пример #11
0
    public void increasePoints()
    {
        points += Mathf.Round(length / GetTime());

        observer.Invoke((int)points);

        PlayerPrefs.SetFloat("points", points);
    }
Пример #12
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Ammo"))
     {
         LevelInfo.life--;
         Destroy(collision.gameObject);
         StartCoroutine(fadeInAndOut(0.1f));
         playerKilled.Invoke(LevelInfo.life);
     }
 }
Пример #13
0
 private void HandleTotalScoreEvent()
 {
     if (!_isSleeping)
     {
         if (_totalScoreCountingEvent != null)
         {
             _totalScoreCountingEvent.Invoke(1);
         }
         _currentScore = 0;
     }
 }
Пример #14
0
    public void Raise(int _value)
    {
        if (defaultBehavior != null)
        {
            defaultBehavior.Invoke(_value);
        }

        for (int i = eventListeners.Count - 1; i >= 0; i--)
        {
            eventListeners[i].OnEventRaised(_value);
        }
    }
 void ApplyTan()
 {
     CurrentTanValue += TanByTurn;
     TanApply.Invoke(CurrentTanValue);
     TanText.text = "TAN : " + CurrentTanValue;
     if (CurrentTanValue >= MaxTanValue)
     {
         //gameOver
         GameStateManager.setGameState(GameState.GameOver);
         SceneManager.LoadSceneAsync(GameOverSceneName);
     }
 }
Пример #16
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "RightCon")
        {
            //Debug.Log("collide");

            imageCollideRight.Invoke();
        }
        else if (other.tag == "LeftCon")
        {
            imageCollideLeft.Invoke();
        }
        ConClick.Invoke(Obj, other.transform);
    }
Пример #17
0
    public void OnDrop(PointerEventData data)
    {
        containerImage.color = normalColor;

        onDropEvent.Invoke(data, this);

        if (receivingImage == null)
        {
            return;
        }

        Sprite dropSprite = GetDropSprite(data);

        if (dropSprite != null)
        {
            receivingImage.overrideSprite = dropSprite;
        }
    }
Пример #18
0
    void GhostAppear(InvocationConfig inv)
    {
        //init Curve
        RefCurve.Frequence = inv.Frequence;
        RefCurve.Dephasage = inv.Dephasage;
        RefCurve.Amplitude = inv.Amplitude;

        lastGhostInvoked = GameObject.Instantiate(Invocations[currentInvocationIndex].prefab, transform);
        ghosts.Add(lastGhostInvoked.GetComponent <Ghost>());
        ghosts[ghosts.Count - 1].FlickerEnd.AddListener(EndFlicker);
        ghosts[ghosts.Count - 1].GoodGoToEnd.AddListener(EndGoodGoTo);
        ghosts[ghosts.Count - 1].KillPlayerStep2.AddListener(HideEnvironment);
        ghosts[ghosts.Count - 1].KillPlayerEnd.AddListener(EndKillPlayer);
        //resetMask
        lastGhostInvoked.GetComponentInChildren <MaskSlideComponent>().VisibleFactor = 0f;

        GhostInvocated.Invoke(numberIngredientStart + Mathf.Max(0, (currentInvocationIndex - 1)) * numberIngredientStep);
    }
Пример #19
0
 /*
  *  When this function is called it ask first for a damage number so it can deduct the damage amount from the current health from the enemy.
  *  After that it sets the slider which in this case is used as a healthbar visual indicator.
  *  Next it checks if the hp is 0 or below 0 so it can call the next function or else it plays a sound of the enemy getting hit + the animation.
  */
 public void DoDamage(int damage)
 {
     if (!_isDead)
     {
         _currentHealth -= damage;
         OnHealthChange.Invoke(damage);
         if (_currentHealth <= 0)
         {
             _isDead = true;
             OnDeath.Invoke();
         }
         else
         {
             FindObjectOfType <PlayerAudio>().PlaySound("HitEnemy");
             FindObjectOfType <CallAnimations>().EnemyAnimaton("RecievedDamage", true);
         }
     }
 }
Пример #20
0
    void Update()
    {
        if (Input.anyKeyDown)
        {
            // イベント関数の呼び出し
            myEvent.Invoke();

            // 追加された関数がInvokeの引数に関係なくインスペクター上で追加したものは呼ばれてる。どういう仕組み?
            myEvent_1.Invoke(1);
        }

        if (Input.GetKeyDown("q"))
        {
            Debug.Log("Quitting Remove MyEvent");
            // UnityEvent から非永続的なリスナーを削除
            myEvent.RemoveListener(MyEvent);

            // インスペクター上で登録したものはどうなるか?
            myEvent_1.RemoveAllListeners();
            // イベントからすべての非永続的な (つまり、スクリプトから作成された) リスナーのみを削除
        }
    }
    public void handleChangeTurnEvent(TurnState state)
    {
        if (state == TurnState.GenerationTurn) //player turn is Over
        {
            if (!playerMove)
            {
                int previousBreakDown = CurrentBreakDownValue;
                int previousTan       = CurrentTanValue;
                ApplyTan();
                ApplyNearTourist();

                if (previousBreakDown == CurrentBreakDownValue && CurrentTanValue > previousTan)
                {
                    TanApplyButNoBreakDown.Invoke(CurrentTanValue);
                }
            }
        }
        else if (state == TurnState.PlayerTurn)
        {
            PLayerChill.Invoke();
            playerMove = false;
        }
    }
Пример #22
0
    private void HandleEvents()
    {
        float _currentTime = 0f;

        _currentTime += Time.deltaTime;

        if (_student._isSleeping)
        {
            _asleepEvent.Invoke(1);
        }

        if (!_student._isSleeping)
        {
            _awakeEvent.Invoke(1);
        }


        Debug.Log("Event handler: is Teacher WATCHING? " + _isTeacherWatching);
        // doesn't work as the teacher is watching even if not
        if (!_isTeacherWatching)
        {
            _fallOkEvent.Invoke(1);
        }
    }
Пример #23
0
 public void OnEventRaised(int value)
 {
     Response.Invoke(value);
 }
Пример #24
0
 public void OnEventRaised(int integerData)
 {
     Response.Invoke(integerData);
 }
Пример #25
0
 void OnDestroy()
 {
     debrisDestroyed.Invoke(m_BelongToLane);
 }
Пример #26
0
 void AddStamina()
 {
     stamina += 10;
     whenLoseStamina.Invoke(stamina.ToString());
 }
Пример #27
0
 public void CallOnColorButtonPressed(int colorButtonID)
 {
     Debug.Log("unpress ColorButton");
     colorPressed = colorButtonID;
     unpressColorButton.Invoke(colorButtonID);
 }
Пример #28
0
 public void CallOnFormButtonPressed(int buttonID)
 {
     Debug.Log("unpress Button");
     buttonPressed = buttonID;
     unpressButton.Invoke(buttonID);
 }
Пример #29
0
 private void finishedBlock()
 {
     Debug.Log("creation button unpressed");
     created = true;
     blockFinished.Invoke(1);
 }
Пример #30
0
 private void finishedScene()
 {
     Debug.Log("finished new Scene");
     sceneFinished.Invoke(1); //Next and Back Button need the ID 0 so that the Position will be reverted into the original Position (no Problem if they are already in that position)
 }