Пример #1
0
    public void DrainEnergyWave(GameObject user)
    {
        ItemBuffMonobehavior obj = new ItemBuffMonobehavior();

        obj.generateObject(affectorObject, user);
        Collider2D[] colliders = Physics2D.OverlapCircleAll(user.transform.position, radius);
        foreach (Collider2D itemCollider2D in colliders)
        {
            GameObject item = itemCollider2D.gameObject;
            if (item == user)
            {
                continue;
            }
            var playerManagerScript = item.GetComponent <PlayerManager>();
            if (playerManagerScript)
            {
                float realDrainAmount = 0f;
                if (playerManagerScript.energy > value)
                {
                    realDrainAmount = value;
                }
                else
                {
                    realDrainAmount = playerManagerScript.energy;
                }
                //playerManagerScript. -= realDrainAmount;
                item.GetComponent <PhotonView>().RPC("ModifyEnergy", RpcTarget.All, -realDrainAmount);
                user.GetComponent <PlayerManager>().energy += realDrainAmount;
                DrainAnimation(10, item.transform.position, user);
            }
        }
    }
Пример #2
0
    public void ShockWave(GameObject user)
    {
        ItemBuffMonobehavior obj = new ItemBuffMonobehavior();

        obj.generateObject(affectorObject, user);
        Collider2D[] colliders = Physics2D.OverlapCircleAll(user.transform.position, radius);
        foreach (Collider2D itemCollider2D in colliders)
        {
            GameObject item = itemCollider2D.gameObject;
            if (item == user)
            {
                continue;
            }
            Vector3 forceDirection = -(user.transform.position - item.transform.position);
            forceDirection[2] = 0;
            var rb = item.GetComponent <Rigidbody2D>();
            if (rb)
            {
                rb.AddForce(forceDirection * value, ForceMode2D.Impulse);
            }
            //item.GetComponent<Rigidbody2D>().AddForce(forceDirection * value,ForceMode2D.Impulse);
        }
    }