Example #1
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        ShipEngine engine = other.gameObject.GetComponent <ShipEngine>();

        if (engine)
        {
            engine.Kill();
        }
        OriginFactory.Reclaim(this);
    }
    public void Recycle()
    {
        for (int i = 0; i < _behaviorList.Count; i++)
        {
            Destroy(_behaviorList[i]);
        }
        _behaviorList.Clear();

        OriginFactory.Reclaim(this);
    }
Example #3
0
 public void Recycle()
 {
     Age = 0f;
     for (int i = 0; i < behaviorList.Count; i++)
     {
         behaviorList[i].Recycle();
         //Destroy(behaviorList[i]);
     }
     behaviorList.Clear();
     OriginFactory.Reclaim(this);
 }
Example #4
0
 public void Recycle()
 {
     Age         = 0f;
     InstanceId += 1;
     for (int i = 0; i < behaviorList.Count; i++)
     {
         behaviorList[i].Recycle();
     }
     behaviorList.Clear();
     OriginFactory.Reclaim(this);
 }
Example #5
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        ShipEngine engine = collision.gameObject.GetComponent <ShipEngine>();

        if (engine)
        {
            engine.Kill();
            DoExplosion(collision);
        }
        OriginFactory.Reclaim(this);
    }
    private void OnCollisionEnter2D(Collision2D other)
    {
        ShipEngine engine = other.gameObject.GetComponent <ShipEngine>();

        if (engine)
        {
            engine.Kill();
        }
        Instantiate(smallExplosion, transform.position, Quaternion.identity);
        OriginFactory.Reclaim(this);
    }
Example #7
0
 public override bool GameUpdate()
 {
     age += Time.deltaTime;
     if (age >= duration || target == null)
     {
         OriginFactory.Reclaim(this);
         return(false);
     }
     target.Enemy.additionalArmor -= 10f;
     return(true);
 }
Example #8
0
 public void Recycle()
 {
     Age = 0f;
     InstanceId++;
     // 回收的时候移除所有的行为
     foreach (var behaviour in behaviours)
     {
         behaviour.Recycle();
     }
     behaviours.Clear();
     OriginFactory.Reclaim(this);
 }
        public override bool GameUpdate()
        {
            age += Time.deltaTime;
            if (age >= duration)
            {
                OriginFactory.Reclaim(this);
                return(false);
            }

            ExplosionEffect();
            return(true);
        }
Example #10
0
    public void Recycle()
    {
        Age         = 0f;
        InstanceId += 1;

        for (int i = 0; i < behaviourList.Count; ++i)
        {
            //Destroy(behaviourList[i]);
            behaviourList[i].Recyle();
        }
        behaviourList.Clear();
        OriginFactory.Reclaim(this);
    }
Example #11
0
    public override bool GameUpdate()
    {
        age += Time.deltaTime;
        if (age >= duration)
        {
            OriginFactory.Reclaim(this);
            return(false);
        }
        if (propertyBlock == null)
        {
            propertyBlock = new MaterialPropertyBlock();
        }
        float t = age / duration;

        transform.localScale = Vector3.one * (scale * scaleCurve.Evaluate(t));
        return(true);
    }
Example #12
0
        public override bool GameUpdate()
        {
            age += Time.deltaTime;
            Vector3 p = launchPoint + launchVelocity * age;

            p.y -= 0.5f * 9.81f * age * age;

            if (p.y <= 0f)
            {
                Game.SpawnExplosion().Initialize(targetPoint, blastRadius, damage);
                OriginFactory.Reclaim(this);
                return(false);
            }
            transform.localPosition = p;

            RotateToDestination();
            return(true);
        }
Example #13
0
 public override bool GameUpdate()
 {
     age += Time.deltaTime;
     if (age >= duration)
     {
         OriginFactory.Reclaim(this);
         return false;
     }
     if (propertyBlock == null)
     {
         propertyBlock = new MaterialPropertyBlock();
     }
     float t = age / duration;
     Color c = Color.clear;
     c.a = opacityCurve.Evaluate(t);
     propertyBlock.SetColor(colorPropertyID, c);
     meshRenderer.SetPropertyBlock(propertyBlock);
     transform.localScale = Vector3.one * (scale * scaleCurve.Evaluate(t));
     return true;
 }
Example #14
0
    public override bool GameUpdate()
    {
        // Follow trajectory
        age += Time.deltaTime;
        Vector3 p = launchPoint + launchVelocity * age;

        p.y -= 0.5f * 9.81f * age * age;

        // Destroy on impact
        if (p.y <= 0f)
        {
            Game.SpawnExplosion().Initialize(targetPoint, blastRadius, damage);
            OriginFactory.Reclaim(this);
            return(false);
        }

        transform.localPosition = p;

        // Align shell
        // Catlike method
        if (usePositionForRotation)
        {
            Vector3 d = launchVelocity;
            d.y += (Physics.gravity.y * age);
            transform.localRotation = Quaternion.LookRotation(d);
        }
        // Joe method
        else
        {
            if (prevPos != Vector3.zero)
            {
                transform.rotation = Quaternion.LookRotation(p - prevPos);
            }
        }
        transform.Rotate(90, 0, 0);
        prevPos = p;

        // Tracer effect
        Game.SpawnExplosion().Initialize(p, 0.1f);
        return(true);
    }
Example #15
0
    public override bool GameUpdate()
    {
        age += Time.deltaTime;
        Vector3 p = launchPoint + launchVelocity * age;

        p.y -= 0.5f * 9.81f * age * age;
        if (p.y <= 0f)
        {
            Game.SpawnExplosion().Initialize(targetPoint, blastRadius, demage);
            OriginFactory.Reclaim(this);
            return(false);
        }
        transform.localPosition = p;

        Vector3 d = launchVelocity;

        d.y -= 9.81f * age;
        transform.localRotation = Quaternion.LookRotation(d);

        Game.SpawnExplosion().Initialize(p, 0.1f);
        return(true);
    }
Example #16
0
 public void Recycle()
 {
     OriginFactory.Reclaim(this);
 }