示例#1
0
    public override void Damage(int value, int playerId)
    {
        if (playerId != input.PlayerId)
        {
            Life -= value;

            PooledBullet bullet   = pxHit.Get <PooledBullet>(true);
            var          position = transform.position;
            position.z = bullet.transform.position.z;
            bullet.transform.position = position;
            tintManager.Tint(Color.red, 0.5f);
        }

        if (Life <= 0)
        {
            if (isDeactivate)
            {
                gameObject.SetActive(false);
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }
示例#2
0
    void Update()
    {
        if (nextSpawnDate < Time.time)
        {
            GameObject target = null;
            foreach (var p in FightManager.Instance.Players) // FIXME use LINQ
            {
                if (p != null)
                {
                    if ((selfTarget && p.playerId == PlayerId) || (!selfTarget && p.playerId != PlayerId))
                    {
                        target = p.gameObject;
                        break;
                    }
                }
            }

            if (target == null)
            {
                return;
            }

            PooledBullet go = prefab.Get <PooledBullet>(true);
            go.transform.position = shootTransform.position;
            go.GetComponent <PlayerObject>().PlayerId = PlayerId;
            go.GetComponent <Rigidbody2D>().velocity  = velocity * (target.transform.position - shootTransform.position).normalized;
            nextSpawnDate = Time.time + cooldown;
        }
    }
示例#3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (isWaitingCrash)
        {
            isWaitingCrash = false;
            if (Time.time < startDate + minDuration)
            {
                animationManager.Command = "jump";
                playerMana.Mana         += cost * 0.5f;
                ClearRunningCommand();
                return;
            }
            StartCoroutine(Locker());

            /* playerCondition.AddCondition(new PlayerCondition.Condition()
             * {
             *  originator = gameObject,
             *  handicap = PlayerCondition.Handicap.MOVE,
             *  type = PlayerCondition.Type.DIVERECOVER,
             *  endDate = Time.time + 2,
             *  cancels = new PlayerCondition.Type[] {PlayerCondition.Type.DIVE},
             *  priority = 10,
             *  retrigger = PlayerCondition.Retrigger.IGNORE
             * }); */
            PooledBullet blast = prefab.Get <PooledBullet>(true);

            blast.transform.position = transform.position;
            body.velocity            = Vector3.zero;
            blast.GetComponent <PlayerObject>().PlayerId = input.PlayerId;
            animationManager.Command = postAnimation;
        }
    }
示例#4
0
    void Place(PooledBullet bullet)
    {
        bullet.transform.position = transform.position + distance * new Vector3(dir.x, dir.y, 0).normalized;
        bullet.GetComponent <Rigidbody2D>().velocity = dir * velocity;
#if SPINE
        bullet.GetComponent <SimpleBullet>().ForceVelocity = dir * velocity;
#endif
    }
示例#5
0
    void Place(PooledBullet bullet)
    {
        bullet.transform.position = transform.position + distance * new Vector3(dir.x, dir.y, 0).normalized;

        /* var angle = Mathf.Rad2Deg * Mathf.Atan2(dir.y, dir.x);
         * bullet.transform.transform.rotation = Quaternion.Euler(0, 0, angle); */

        bullet.GetComponent <Rigidbody2D>().velocity  = dir * velocity;
        bullet.GetComponent <PlayerObject>().PlayerId = input.PlayerId;
    }
示例#6
0
    void Update()
    {
        if (!Check())
        {
            return;
        }

        PooledBullet bullet = prefab.Get <PooledBullet>(true);

        Debug.Log("place " + bullet.name);
        Place(bullet);
    }
示例#7
0
    void CreateBullets()
    {
        Vector3 currentDir = multi == 1 ? new Vector3(dir.x, dir.y, 0) : Quaternion.Euler(0, 0, -multiAngle * 0.5f) * dir;

        for (int i = 0; i < multi; i++)
        {
            PooledBullet bullet = prefab.Get <PooledBullet>(true);
            bullet.GetComponent <PlayerObject>().PlayerId = input.PlayerId;
            Place(bullet, currentDir);
            currentDir = Quaternion.Euler(0, 0, multiAngle / multi) * currentDir;
        }
    }
示例#8
0
 void OnPreRender()
 {
     if (ModuleWeapon.bulletPool)
     {
         for (int i = 0; i < ModuleWeapon.bulletPool.size; i++)
         {
             if (ModuleWeapon.bulletPool.GetPooledObject(i).activeInHierarchy)
             {
                 PooledBullet pBullet = ModuleWeapon.bulletPool.GetPooledObject(i).GetComponent <PooledBullet>();
                 pBullet.UpdateWidth(cam, resizeFactor);
             }
         }
     }
 }
示例#9
0
 void Update()
 {
     if (Time.time > dateOk)
     {
         if (input.A)
         {
             PooledBullet bullet = prefab.Get <PooledBullet>(true);
             bullet.transform.position += transform.position + Vector3.up;
             bullet.GetComponent <Rigidbody2D>().velocity = GetComponent <Rigidbody2D>().velocity.normalized * 10;
             bullet.name = "b" + cnt++;
             dateOk     += cooldown;
         }
     }
 }
示例#10
0
    protected virtual void Update()
    {
        if (!Check())
        {
            return;
        }
        if (prefab == null)
        {
            return;
        }

        PooledBullet bullet = prefab.Get <PooledBullet>(true);

        Debug.Log("place " + bullet.name);
        Place(bullet);
    }
示例#11
0
    void Update()
    {
        if (!Check())
        {
            return;
        }

        PooledBullet bullet = prefab.Get <PooledBullet>(true);

        FindClosestTarget();
        if (target != null)
        {
            dir = (target.position - transform.position).normalized;
            dir = RestrainAngle();
            Place(bullet);
        }
    }
示例#12
0
    void Place(PooledBullet bullet, Vector2 localDir)
    {
        bullet.transform.position = transform.position + distance * new Vector3(localDir.x, localDir.y, 0).normalized;

        /* var angle = Mathf.Rad2Deg * Mathf.Atan2(dir.y, dir.x);
         * bullet.transform.transform.rotation = Quaternion.Euler(0, 0, angle); */

        bullet.GetComponent <Rigidbody2D>().velocity = localDir * velocity;
#if SPINE
        var sb = bullet.GetComponent <SimpleBullet>();

        if (sb != null)
        {
            sb.ForceVelocity = localDir * velocity;
        }
#endif
        bullet.GetComponent <PlayerObject>().PlayerId = input.PlayerId;
    }
示例#13
0
    void Update()
    {
        var newDir = new Vector2(input.X, input.Y).normalized;

        if (newDir.magnitude > Mathf.Epsilon)
        {
            dir = newDir;
        }

        if (!Check())
        {
            return;
        }

        PooledBullet bullet = prefab.Get <PooledBullet>(true);

        dir = RestrainAngle();
        Place(bullet);
    }
示例#14
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (isWaitingCrash)
        {
            isWaitingCrash = false;
            playerCondition.AddCondition(new PlayerCondition.Condition()
            {
                originator = gameObject,
                handicap   = PlayerCondition.Handicap.MOVE,
                type       = PlayerCondition.Type.DIVERECOVER,
                endDate    = Time.time + 2,
                cancels    = new PlayerCondition.Type[] { PlayerCondition.Type.DIVE },
                priority   = 10,
                retrigger  = PlayerCondition.Retrigger.IGNORE
            });
            PooledBullet blast = prefab.Get <PooledBullet>(true);

            blast.transform.position = transform.position;
            body.velocity            = Vector3.zero;
            blast.GetComponent <PlayerObject>().PlayerId = input.PlayerId;
        }
    }
示例#15
0
    public override void Damage(int value, int playerId)
    {
        if (playerId != playerObject.PlayerId)
        {
            Life -= value;
        }

        PooledBullet bullet   = pxHit.Get <PooledBullet>(true);
        var          position = transform.position;

        position.z = bullet.transform.position.z;
        bullet.transform.position = position;
        if (fill != null)
        {
            fill.fillAmount = (float)Life / (float)lifeBase;
        }


        if (Life <= 0)
        {
            gameObject.SetActive(false);
        }
    }
示例#16
0
    void Update()
    {
        if (!Check())
        {
            return;
        }

        if (isGravityCancel)
        {
            StartCoroutine(GravityCancel());
        }

        PooledBullet bullet = prefab.Get <PooledBullet>(true);

        bullet.GetComponent <PlayerObject>().PlayerId = input.PlayerId;

        FindClosestTarget();
        if (target != null)
        {
            dir = (target.position - transform.position).normalized;
            dir = RestrainAngle();
            Place(bullet);
        }
    }
示例#17
0
 void Place(PooledBullet bullet)
 {
     bullet.transform.position = transform.position + distance * new Vector3(dir.x, dir.y, 0).normalized;
     bullet.GetComponent <Rigidbody2D>().velocity = dir * velocity;
 }
示例#18
0
 void Place(PooledBullet bullet)
 {
     bullet.transform.position = dropTransform.position;
     bullet.GetComponent <PlayerObject>().PlayerId = input.PlayerId;
     MaxOut(bullet.gameObject);
 }