Esempio n. 1
0
 protected override void OnCollisionPlayerProjectile(GameObject hit, CollisionPhase phase)
 {
     // ISSUE: reference to a compiler-generated field
     if (this.OnPlayerProjectileCollision == null)
     {
         return;
     }
     // ISSUE: reference to a compiler-generated field
     this.OnPlayerProjectileCollision(hit, phase);
 }
Esempio n. 2
0
    protected override void OnCollisionOther(GameObject hit, CollisionPhase phase)
    {
        if (!enabled)
        {
            return;
        }

        if (phase == CollisionPhase.Enter)
        {
            OnHitOtherEnterEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
    }
Esempio n. 3
0
    protected override void OnCollisionEnemy(GameObject hit, CollisionPhase phase)
    {
        if (!enabled)
        {
            return;
        }

        if (phase == CollisionPhase.Enter)
        {
            OnHitEnemyEnterEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
        else if (phase == CollisionPhase.Stay)
        {
            OnHitEnemyStayEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
        else
        {
            OnHitEnemyExitEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
    }
Esempio n. 4
0
    protected override void OnCollisionPlayer(GameObject hit, CollisionPhase phase)
    {
        if (!enabled)
        {
            return;
        }

        //Debug.Log("AttackEventListener".Colored(Colors.green) + " OnCollisionPlayer : " + hit.ToString().Colored(Colors.cyan));
        if (phase == CollisionPhase.Enter)
        {
            OnHitPlayerEnterEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
        else if (phase == CollisionPhase.Stay)
        {
            OnHitPlayerStayEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
        else
        {
            OnHitPlayerExitEvent?.Invoke(hit, hit.GetComponent <Collider2D>().bounds.center);
        }
    }
    protected virtual void checkCollision(Collider2D col, CollisionPhase phase)
    {
        GameObject gameObject = col.gameObject;

        this.OnCollision(gameObject, phase);

        string tag   = gameObject.tag;
        string layer = LayerMask.LayerToName(gameObject.layer);

        //Debug.Log("AttackEventListener checkCollision() + " + col.gameObject.ToString().Colored(Colors.cyan) + " " + layer.Colored(Colors.yellow));

        if (tag == Tags.Monster.ToString() || tag == Tags.MonsterBody.ToString())
        {
            if (!this.allowCollisionEnemy)
            {
                return;
            }
            this.OnCollisionEnemy(gameObject, phase);
        }
        else if (tag == Tags.Player.ToString() || tag == Tags.PlayerBody.ToString())
        {
            if (!this.allowCollisionPlayer)
            {
                return;
            }
            this.OnCollisionPlayer(gameObject, phase);
        }
        else if (layer == Tags.DefenseBody.ToString())
        {
            //this.OnCollisionEnemy(gameObject, phase);
            this.OnCollisionPlayer(gameObject, phase);
        }
        else
        {
            this.OnCollisionOther(gameObject, phase);
        }
    }
    public override void ShowGui(RuleData ruleData)
    {
        GUILayout.Label("On Collision of", RuleGUI.ruleLabelStyle);

        // actor dropdown
        int resultIndex = actorDropDown.Draw();
        if (resultIndex > -1)
        {
            int resultId = generator.Gui.GetActorDataByLabel(actorDropDown.Content[resultIndex].text).id;

            (ruleData as EventData).actorId = resultId;
            if (Actor.Id != resultId)
                generator.ChangeActor(this, resultId);
        }

        GUILayout.Label("and", RuleGUI.ruleLabelStyle);

        resultIndex = chooseObjectKindDropDown.Draw();
        if (resultIndex == 0) // tag
        {
            CollideWithActor = null;
            // tag dropdown
            resultIndex = tagDropDown.Draw();
            if (resultIndex >= 0)
            {
                string resultTag = tagDropDown.Content[resultIndex].text;

                if (resultTag.Length > 0)
                {
                    CollideWithTag = resultTag;
                    ChangeParameter("CollideWithTag", (ruleData as EventData).parameters, CollideWithTag);
                }
            }
        }
        else if (resultIndex == 1) // actor
        {
            resultIndex = collisionActorDropDown.Draw();
            if (resultIndex > -1)
            {
                int resultId = generator.Gui.GetActorDataByLabel(collisionActorDropDown.Content[resultIndex].text).id;

                CollideWithActor = generator.GetActor(resultId);
                ChangeParameter("CollideWithActor", ruleData.parameters, CollideWithActor.Id);
            }
        }

        GUILayout.Label("when", RuleGUI.ruleLabelStyle);

        // trigger dropdown
        resultIndex = triggerDropDown.Draw();
        if (resultIndex >= 0)
        {
            TriggerOn = (CollisionPhase)resultIndex;
            ChangeParameter("TriggerOn", (ruleData as EventData).parameters, TriggerOn);
        }

        GUILayout.Label("collision", RuleGUI.ruleLabelStyle);
    }
 protected virtual void OnCollisionOther(GameObject hit, CollisionPhase phase)
 {
 }
 protected virtual void OnCollisionPlayerProjectile(GameObject hit, CollisionPhase phase)
 {
 }
 protected virtual void OnCollisionEnemy(GameObject hit, CollisionPhase phase)
 {
 }
 protected virtual void OnCollisionGround(GameObject hit, CollisionPhase phase)
 {
 }
 protected virtual void OnCollisionCeiling(GameObject hit, CollisionPhase phase)
 {
 }
 protected virtual void OnCollisionWalls(GameObject hit, CollisionPhase phase)
 {
 }