コード例 #1
0
    public override bool Cast()
    {
        bool wasCast = false;

        SpinAttackEffect.Create(radius);
        effectAlpha = 1f;

        Vector2 playerPosition = player.GetComponent <Rigidbody2D>().position;

        RaycastHit2D[] hits = Physics2D.CircleCastAll(playerPosition, radius, playerPosition);
        foreach (RaycastHit2D hit in hits)
        {
            if (hit != null && hit.collider != null)
            {
                if (hit.collider.gameObject.GetComponent <EnemyController>() != null)
                {
                    // CombatText combatText = hit.collider.gameObject.AddComponent(typeof(CombatText)) as CombatText;
                    // combatText.text= damage.ToString();
                    CombatText.Create(hit.collider.gameObject.transform.position, 100.ToString(), false);
                    hit.collider.gameObject.GetComponent <CombatTextFactory>().addCombatText("Hit Enemy with spin");
                    Debug.Log("Hit Enemy with spin");
                }
            }
        }

        wasCast = true;

        Debug.Log("Cast SpinAttack");
        return(wasCast);
    }
コード例 #2
0
    public static SpinAttackEffect Create(float effectRadius)
    {
        // CombatText.Create(Vector2.zero, "TEST");
        Transform        spinEffectTransform = Instantiate(GameAssets.i.spinEffect, Vector3.zero, Quaternion.identity);
        SpinAttackEffect spinEffect          = spinEffectTransform.GetComponent <SpinAttackEffect>();

        spinEffect.Setup(effectRadius);
        return(spinEffect);
    }