コード例 #1
0
ファイル: HeroManager.cs プロジェクト: ma-chu/BattleRoyal
    // Функции-запускатели событий этого класса, что подписываются на GameManager.ExchangeEvent1-2
    private void OnExchange1()
    {
        if ((preCoeffs[0].exchangeResult == ExchangeResult.GetHit) || (preCoeffs[0].exchangeResult == ExchangeResult.BlockVs2Handed))
        {
            GetHitEvent?.Invoke(1);
            if (_HP.TakeDamage(/*damage1*/ gotDamage))
            {
                InvokeDeathEvent();
            }
        }

        if (decision == Decision.Attack)
        {
            if (preCoeffs[0].exchangeResult == ExchangeResult.Parry)
            {
                ParryEvent?.Invoke(1);
            }
            if (preCoeffs[0].exchangeResult == ExchangeResult.Block)
            {
                BlockEvent?.Invoke(1);
            }
            if (preCoeffs[0].exchangeResult == ExchangeResult.BlockVs2Handed)
            {
                BlockVs2HandedEvent?.Invoke();
            }
        }

        if (preCoeffs[0].exchangeResult == ExchangeResult.Evade)
        {
            EvadeEvent?.Invoke(1);
        }
    }
コード例 #2
0
ファイル: Block.cs プロジェクト: RomanPay/WackyBreakout
 /// <summary>
 /// Destroys the block on collision with ball
 /// </summary>
 /// <param name="other">collider</param>
 protected virtual void OnCollisionEnter2D(Collision2D other)
 {
     _addPoints.Invoke(CostBlock);
     _blockEvent.Invoke();
     AudioManager.Play(AudioClipName.HitBlock);
     Destroy(gameObject);
 }
コード例 #3
0
ファイル: GroundCheck.cs プロジェクト: Mpprobst/ML_Runner
        void Update()
        {
            Vector2 left   = new Vector2(m_Collider2D.bounds.max.x, m_Collider2D.bounds.center.y);
            Vector2 center = new Vector2(m_Collider2D.bounds.center.x, m_Collider2D.bounds.center.y);
            Vector2 right  = new Vector2(m_Collider2D.bounds.min.x, m_Collider2D.bounds.center.y);

            RaycastHit2D hit1 = Physics2D.Raycast(left, new Vector2(0f, -1f), m_RayDistance, LayerMask.GetMask(GROUND_LAYER_NAME));

            Debug.DrawRay(left, new Vector2(0f, -m_RayDistance));
            bool grounded1 = hit1 != null && hit1.collider != null && hit1.collider.CompareTag(GROUND_TAG);

            RaycastHit2D hit2 = Physics2D.Raycast(center, new Vector2(0f, -1f), m_RayDistance, LayerMask.GetMask(GROUND_LAYER_NAME));

            Debug.DrawRay(center, new Vector2(0f, -m_RayDistance));
            bool grounded2 = hit2 != null && hit2.collider != null && hit2.collider.CompareTag(GROUND_TAG);

            // when we no longer see that we are grounded, wait for landing
            if (!grounded2 && land)
            {
                land = false;
            }
            if (grounded2 && !land)
            {
                land = true;
                landEvent.Invoke(hit2.collider.transform.parent.transform.parent.gameObject);
            }

            RaycastHit2D hit3 = Physics2D.Raycast(right, new Vector2(0f, -1f), m_RayDistance, LayerMask.GetMask(GROUND_LAYER_NAME));

            Debug.DrawRay(right, new Vector2(0f, -m_RayDistance));
            bool grounded3 = hit3 != null && hit3.collider != null && hit3.collider.CompareTag(GROUND_TAG);

            bool grounded = grounded1 || grounded2 || grounded3;

            if (grounded && !m_IsGrounded)
            {
                if (OnGrounded != null)
                {
                    OnGrounded();
                }
            }

            m_IsGrounded = grounded;
        }
コード例 #4
0
ファイル: Block.cs プロジェクト: KevinAssink/Shippable-Game
    void ProcessCollision(Collision collision)
    {
        //Vector3 edge = collision.contacts[0].point - collision.contacts[1].point;

        Debug.Log(string.Format("Block.ProcessCollision: {0} ({1}|{2}) on {3}({4})", name
                                , isFlying?"Flying":"", IsOnStack?"OnStack":""
                                , collision.gameObject.name, collision.gameObject.tag
                                ));
        if (!this.isFlying && !this.isOnStack)
        {
            body             = GetComponent <Rigidbody>();
            body.isKinematic = true;
            if (collision.gameObject.tag.Equals("Ground"))
            {
                isOnGround = true;

                if (onGroundListener != null)
                {
                    onGroundListener.Invoke(this);
                }
            }
            else if (collision.gameObject.tag.Equals("Block"))
            {
                Block targetBlock = collision.gameObject.GetComponent <Block>();
                if (onBlockListener != null)
                {
                    onBlockListener.Invoke(this, targetBlock, collision);
                }
                else
                {
                    Debug.Log(string.Format("- NoListener!"));
                }

                foreach (ContactPoint point in collision.contacts)
                {
                    Debug.Log(string.Format("- Point: {0}", point.point.ToString()));
                }
                lastCollision = collision;
            }
        }
    }
コード例 #5
0
        // Update is called once per frame
        void Update()
        {
            //if (Input.GetAxis("Moving") != 0 && MoveEvent != null)
            //    MoveEvent.Invoke(Input.GetAxis("Moving"));

            if (MoveEvent != null)
            {
                MoveEvent.Invoke(Input.GetAxis("Moving"));
            }

            if (Input.GetKeyDown(KeyCode.Space) && CryEvent != null)
            {
                CryEvent.Invoke(Input.GetAxis("Cry"));
            }

            if ((Input.GetKeyDown(KeyCode.RightControl) || Input.GetKeyDown(KeyCode.LeftControl)) && BlockEvent != null)
            {
                BlockEvent.Invoke(Input.GetAxis("Block"));
            }

            _ExecutingCommands();
        }
コード例 #6
0
ファイル: HeroManager.cs プロジェクト: ma-chu/BattleRoyal
    protected virtual void OnExchange2()
    {
        if (decision == Decision.Attack)
        {
            AttackEvent?.Invoke();
        }

        if ((preCoeffs[1].exchangeResult == ExchangeResult.GetHit) && !m_dead)    // если не помер после первого удара
        {
            GetHitEvent?.Invoke(2);                                               // то принимаем второй
            if (_HP.TakeDamage(/*damage2*/ gotDamage))
            {
                InvokeDeathEvent();
            }
        }

        if (((decision == Decision.ChangeSwordShield) || (decision == Decision.ChangeSwordSword) || (decision == Decision.ChangeTwoHandedSword)) &&
            !m_dead)
        {
            ChangeEvent?.Invoke();
        }
        else
        {
            if (preCoeffs[1].exchangeResult == ExchangeResult.Parry)
            {
                ParryEvent?.Invoke(2);
            }
            if (preCoeffs[1].exchangeResult == ExchangeResult.Block)
            {
                BlockEvent?.Invoke(2);
            }
        }

        if (preCoeffs[1].exchangeResult == ExchangeResult.Evade)
        {
            EvadeEvent?.Invoke(2);
        }
    }
コード例 #7
0
 public void TerminalBlock(object o, EventArgs e)
 {
     BlockEvent?.Invoke(this, e);
 }
コード例 #8
0
ファイル: Block.cs プロジェクト: Hengle/FbxBlockify
 private void OnCollisionEnter(Collision other)
 {
     collisionEvent.Invoke(other, this);
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: ShemetViktoriia/FightClub_2
 private void OnBlock()
 {
     BlockEvent?.Invoke(this, new PlayerEventArgs(Name, healthPoints));
 }