Example #1
0
        void AddedBehavior()
        {
            if (particleSystem != null)
            {
                GameObject newPsys = GameObject.Instantiate(particleSystem.gameObject);
                newPsys.SetActive(true);

                DestroyOnTime dot = newPsys.AddComponent <DestroyOnTime>();

                dot.time = particleSystem.duration * 2f;
            }
        }
Example #2
0
    protected override void OnDie()
    {
        EngineDelegate.instance.CreateEffect("Explode", this.transform.position, Quaternion.identity);
        CharacterController cc = GetComponent <CharacterController>();

        if (cc != null)
        {
            Destroy(cc);
        }
        UnitMotor um = GetComponent <UnitMotor>();

        if (um != null)
        {
            Destroy(um);
        }
        BoxCollider box = this.gameObject.AddComponent <BoxCollider>();

        box.size   = new Vector3(2.0f, 2.0f, 4.0f);
        box.center = new Vector3(0.0f, 2.0f, 0.0f);
        Rigidbody rb = this.gameObject.AddComponent <Rigidbody>();

        if (rb != null)
        {
            rb.useGravity      = true;
            rb.velocity        = new Vector3(0.0f, diedVelocity, 0.0f);
            rb.angularVelocity = new Vector3(0.0f, 0.0f, diedAngularVelocity);
        }

        DestroyOnTime dot = this.gameObject.AddComponent <DestroyOnTime>();

        if (dot != null)
        {
            dot.time = dieDisappearTime;
        }
        gameObject.layer = LayerMask.NameToLayer("UnhitableObject");

        foreach (Transform tran in transform)
        {
            if (tran.gameObject.renderer != null)
            {
                tran.gameObject.renderer.material.color = new Color(0.3f, 0.3f, 0.3f);
            }
        }
    }
Example #3
0
    protected void OnViewerEffectMessage(ViewerEffectMessage message)
    {
        Region region = Agent.CurrentPlayer?.Region;

        if (region == null)
        {
            return;
        }

        foreach (ViewerEffect viewerEffect in message.Effects)
        {
            GameObject go = null;
            switch (viewerEffect)
            {
            case ViewerEffectSpiral spiralEffect:
                go = Instantiate(SpiralEffectPrefab, transform);     // TODO: Use effect pool
                go.transform.position = region.GetLocalPosition(spiralEffect.PositionGlobal);
                break;

            case ViewerEffectLookAt lookAtEffect:
                go = Instantiate(LookAtEffectPrefab, transform);     // TODO: Use effect pool
                go.transform.position = region.GetLocalPosition(lookAtEffect.TargetPosition);
                break;

            case ViewerEffectPointAt pointAtEffect:
                go = Instantiate(PointAtEffectPrefab, transform);     // TODO: Use effect pool
                go.transform.position = region.GetLocalPosition(pointAtEffect.TargetPosition);
                // TODO: Set the source position to the location of the source avatar?
                break;
            }

            if (go == null)
            {
                Logger.LogWarning("ViewerEffectsManager.OnViewerEffectMessage", $"ViewerEffect of type {viewerEffect.EffectType} is not implemented.");
                continue;
            }
            GameObjectByEffectId[viewerEffect.Id] = go;
            DestroyOnTime dot = go.GetComponent <DestroyOnTime>();
            if (dot != null)
            {
                dot.LifeTime = viewerEffect.Duration;
            }
        }
    }