Example #1
0
    public void Init(PlayerController owningPlayer, Vector3 forwardVector, GunType gun)
    {
        gameManager  = GameManager.Instance;
        firedFromGun = gun;

        this.owningPlayer = owningPlayer;
        this.owner        = owningPlayer.playerModel;
        this.lifeTime     = gun.projectileLifetime;

        movementDirection = forwardVector;
        moveSpeed         = gun.projectileSpeed;
        damage            = gun.projectileDamage;

        projectileBody.transform.localScale = new Vector3(gun.projectileSize / 2, gun.projectileSize / 2, gun.projectileSize / 2);

        projectileBody.GetComponent <MeshRenderer>().material.color = Color.white;

        projectileLight.color = TeamManager.Instance.GetTeamColor(owningPlayer.teamID);

        foreach (ParticleSystem ps in particleSystems)
        {
            var main = ps.main;
            main.startColor = TeamManager.Instance.GetTeamColor(owningPlayer.teamID);
        }



        if (OnProjectileOverlap == null)
        {
            OnProjectileOverlap = new ProjectileEvent();
        }
        OnProjectileOverlap.AddListener(OnCollision);

        initialized = true;
    }
Example #2
0
    private void StopEffects(ProjectileEvent events)
    {
        if (_fxHelper == null)
        {
            return;
        }

        // TODO this should stop only the events specified in the events but this might be good enough
        _fxHelper.StopAll(true);         // [GM] set ClearParticles argument to TRUE in order to clear projectile particle on OnHit()
    }
Example #3
0
    private void PlayEffects(ProjectileEvent projectileEvent)
    {
        if (_fxHelper == null)
        {
            return;
        }

        for (int j = 0; j < projectileEvent._particles.Count; ++j)
        {
            MoveEditor.ParticleEventInfo particleEventInfo = projectileEvent._particles[j];

            // Dirty hack here - if the particle's set to spawn at hit point, we call the player's FXHelper
            // the reason being that if we don't then the effects will get destroyed since the projectile would likely be deactivated on hit, thus destroying all its fx
            if (particleEventInfo._particleProperties._spawnAtHitPoint)
            {
                MoveEditor.MoveAnimationEvent moveEvent = new MoveEditor.MoveAnimationEvent()
                {
                    EventRef = particleEventInfo
                };
                _owner.OnHandleMessage("OnPlayParticle", moveEvent);
                //_owner.FXHelper.PlayParticle(particleEventInfo._particleProperties);
            }
            else
            {
                _fxHelper.PlayParticle(particleEventInfo._particleProperties);
            }
        }

        for (int j = 0; j < projectileEvent._trails.Count; ++j)
        {
            MoveEditor.TrailRendererEventInfo trailEventInfo = projectileEvent._trails[j];
            _fxHelper.PlayTrailRenderer(trailEventInfo._trailRendererProperties);
        }

        for (int j = 0; j < projectileEvent._dynamicLights.Count; ++j)
        {
            MoveEditor.DynamicLightEventInfo dynamicLights = projectileEvent._dynamicLights[j];
            _fxHelper.PlayDynamicLight(dynamicLights._dynamicLightProperties);
        }

        AttributeData attr = _owner.OnGetAttributeData("IsCurrentAttackCritical");

        for (int i = 0; i < projectileEvent._cameraShakes.Count; ++i)
        {
            MoveEditor.CameraShakeEventInfo shakeInfo = projectileEvent._cameraShakes[i];
            MoveCameraShakeHelper.Shake(shakeInfo, _owner != null && attr.IsCurrentAttackCritical);
        }
    }
    private void TriggerAction(ProjectileEvent e)
    {
        foreach (var action in e.Actions)
        {
            if (action.Type == ProjectileAction.ActionTypes.Emit)
            {
                var rotationRadians = rb2d.rotation * (Mathf.PI / 180f);
                var direction       = new Vector2(Mathf.Cos(rotationRadians), Mathf.Sin(rotationRadians));
                action.ProjectileEmitter.EmitProjectiles(GetComponent <BoxCollider2D>(), rb2d, direction);
            }
            else if (action.Type == ProjectileAction.ActionTypes.Destroy)
            {
                Destroy(gameObject);
            }
        }

        //TODO: support other action types
    }