Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        // Rotate the key
        transform.Rotate(Vector3.back * (rotationSpeed * Time.deltaTime));

        // Set the colour
        GetComponent <SpriteRenderer>().color = keyColour;

        // If the pickup has been collected
        if (keyCollected)
        {
            // Call back
            if (onKeyCollected != null)
            {
                onKeyCollected.Invoke(gameObject);
            }

            // Play sfx
            questManager.PlaySFX();
            ParticleSystemController.InstaniateParticleSystem(collectable, transform.position, Quaternion.identity);

            // Key has been collected
            chest.GetComponent <Chest>().KeyCollected(true);

            // Remove the key
            gameObject.SetActive(false);
        }
    }
Beispiel #2
0
        public void Resize(bool live)
        {
            if (psCtrl == null)
            {
                gameObject.AddComponent <ParticleSystemController> ();
                psCtrl = GetComponent <ParticleSystemController>();
            }

            if (live)
            {
                if (lineRenderers.Count > 0)
                {
                    for (int i = 0; i < lineRenderers.Count; i++)
                    {
                        lrWidth[i] *= size;
                        lrWidth [i] = (float)System.Math.Round(lrWidth [i], 2);
                    }
                }
                overgrow *= size;
                overgrow  = (float)System.Math.Round(overgrow, 2);
            }

            size        = (float)System.Math.Round(size, 2);
            psCtrl.size = size;
            psCtrl.ResizeOnly();
        }
 public override void init()
 {
     effectColor        = GetComponent <SpriteRenderer>().color;
     effectColor.a      = 1;
     friu               = GetComponent <TeleportRangeIndicatorUpdater>();
     aoeCollider        = GetComponent <CircleCollider2D>();
     particleController = GetComponentInChildren <ParticleSystemController>();
 }
Beispiel #4
0
 void Awake()
 {
     scoreScreen            = scoreScreen.GetComponent <Canvas> ();
     gameOverScreen         = gameOverScreen.GetComponent <Canvas> ();
     gameOverScreen.enabled = false;
     player    = GameObject.FindWithTag("Player");
     explosion = player.GetComponent <ParticleSystemController> ();
 }
 private void OnEnable()
 {
     effectParticleController = GetComponent <ParticleSystemController>();
     effectParticleSystem     = GetComponent <ParticleSystem>();
     ParticleSystem.MainModule psmm = effectParticleSystem.main;
     psmm.startColor = playerAbility.EffectColor.adjustAlpha(psmm.startColor.color.a);
     playerAbility.onEffectedTeleport += processTeleport;
 }
Beispiel #6
0
    public float maxGestureRange = 1;//how far from the center of the player character this ability can activate

    // Use this for initialization
    protected virtual void Start()
    {
        player             = gameObject;
        particleController = teleportParticleEffects.GetComponent <ParticleSystemController>();
        particleSystem     = teleportParticleEffects.GetComponent <ParticleSystem>();
        if (abilityIndicatorParticleEffects != null)
        {
            abilityIndicatorParticleEffects.GetComponent <ParticleSystem>().Play();
        }
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ParticleSystemController psCtrl = (ParticleSystemController)target;

        if (GUILayout.Button("Refresh"))
        {
            psCtrl.UpdateParticleSystem();
        }
    }
        public IEnumerator colorsDifferent()
        {
            GameObject newGameObject = InstantiateGameObjectParticleSystemMidController();

            yield return(null);

            particleSystemController = newGameObject.GetComponent <ParticleSystemController>();
            Color[] colors = { Color.red, Color.blue, Color.black };
            particleSystemController.alterColorOverLifeTime(colors[0], colors[1], colors[2]);
            Gradient gradient = getGradient(colors[0], colors[1], colors[2]);

            Assert.AreEqual(gradient, particleSystemController.particleSystem.colorOverLifetime.color.gradient);
        }
Beispiel #9
0
    public void ToggleLifeIndicator(bool isOn, Image inhalerSprite)
    {
        // change the tint based on on/off
        inhalerSprite.color = isOn ? Color.white : Color.black;

        // play the particle system associated with this toggle, if it exists
        ParticleSystemController system = isOn ? systemOn : systemOff;

        if (system)
        {
            system.Play();
        }
    }
Beispiel #10
0
        public ParticleSystemController Spawn(string particleSystemName, Vector3 spawnPosition)
        {
            ParticleSystemController result = loader.Spawn(particleSystemName, particlesContainer);

            if (result != null)
            {
                result.transform.position = spawnPosition;
                aliveSystems.Add(result);
                SubscribeEvents(result);
            }

            return(result);
        }
        public IEnumerator colorsEqual()
        {
            GameObject newGameObject = InstantiateGameObjectParticleSystemMidController();

            yield return(null);

            particleSystemController = newGameObject.GetComponent <ParticleSystemController>();
            Color color = Color.yellow;

            particleSystemController.alterColorOverLifeTime(color, color, color);
            Gradient gradient = getGradient(color, color, color);

            Assert.AreEqual(gradient, particleSystemController.particleSystem.colorOverLifetime.color.gradient);
        }
 // Use this for initialization
 void Start()
 {
     rb2d          = GetComponent <Rigidbody2D>();
     pc2d          = GetComponent <PolygonCollider2D>();
     gravity       = GetComponent <GravityAccepter>();
     mainCamCtr    = Camera.main.GetComponent <CameraController>();
     gm            = GameObject.FindGameObjectWithTag("GestureManager").GetComponent <GestureManager>();
     halfWidth     = GetComponent <SpriteRenderer>().bounds.extents.magnitude;
     hm            = GetComponent <HardMaterial>();
     hm.shattered += shattered;
     fta           = GetComponent <ForceTeleportAbility>();
     wca           = GetComponent <WallClimbAbility>();
     sba           = GetComponent <ShieldBubbleAbility>();
     teleportRangeParticalController = teleportRangeParticalObject.GetComponent <ParticleSystemController>();
 }
Beispiel #13
0
        void Start()
        {
            //Changes color
            psCtrl = GetComponent <ParticleSystemController>();
            if (psCtrl == null && size != 1 || changeColor)
            {
                gameObject.AddComponent <ParticleSystemController> ();
                psCtrl = GetComponent <ParticleSystemController>();
            }

            if (changeColor)
            {
                psCtrl.changeColor = changeColor;
                psCtrl.newMaxColor = newMaxColor;
                psCtrl.newMinColor = newMinColor;
                psCtrl.ChangeColorOnly();
                for (int i = 0; i < lineRenderers.Count; i++)
                {
                    lineRenderers [i].colorGradient = psCtrl.ChangeGradientColor(lineRenderers [i].colorGradient, psCtrl.newMaxColor, psCtrl.newMinColor);
                }
            }
            if (size != 1)
            {
                Resize(false);
            }

            //if the end point is a camera than get the componenet
            if (endPoint != null)
            {
                cam = endPoint.GetComponent <Camera> ();
            }

            if (layerName != "Default")
            {
                var layerID = LayerMask.NameToLayer(layerName);
                if (layerID != -1)
                {
                    gameObject.layer = layerID;
                    ChangeLayerRecursively(gameObject);
                }
                else
                {
                    Debug.Log("That Layer Name doesn't exist. Watchout for a typo!");
                }
            }

            FillLists();
        }
Beispiel #14
0
    // Called when the cube has taken damage
    public void CubeDamaged(int damage)
    {
        // Remove health from cube
        currentHealth -= damage;

        // If the cube damaged is a rock play particle effects
        if (cubeType == CUBETYPE.ROCK)
        {
            // If the cube has been damaged
            if (currentHealth > 0)
            {
                ParticleSystemController.InstaniateCubeParticleSystem(map.rockDamagedSystem, transform);
                soundFx.PlayOneShot(rockDamagedClip, 0.25f);
            }

            // Cube has been destroyed
            else
            {
                ParticleSystemController.InstaniateCubeParticleSystem(map.rockDestroyedSystem, transform);
                soundFx.PlayOneShot(rockDestroyedClip, 0.25f);
            }

            // Camera shake
            CameraShaker.Instance.Shake(CameraShakePresets.RockDamaged);
        }

        // If the cube damaged is a crystal play particle effects
        if (cubeType == CUBETYPE.CRYSTAL)
        {
            // If the cube has been damaged
            if (currentHealth > 0)
            {
                ParticleSystemController.InstaniateCubeParticleSystem(map.crystalDamagedSystem, transform);
                soundFx.PlayOneShot(crystalDamagedClip);
            }

            // Cube has been destroyed
            else
            {
                ParticleSystemController.InstaniateCubeParticleSystem(map.crystalDestroyedSystem, transform);
                soundFx.PlayOneShot(crystalDestroyedClip);
            }

            // Camera shake
            CameraShaker.Instance.Shake(CameraShakePresets.CrystalDamaged);
        }
    }
Beispiel #15
0
    //base function for ranged attack that can be overridden for unique behaviour
    protected virtual void RangedAttack()
    {
        //Play the gunshot flash
        GameObject FlashParticleObject = ObjectPoolManager.Instance.GetObjectFromNetworkPool(m_GunFlashParticlePoolName);

        if (FlashParticleObject != null)
        {
            FlashParticleObject.SetActive(true);
            ParticleSystemController particleController = FlashParticleObject.GetComponent <ParticleSystemController>();

            if (GunFlashLocation != null)
            {
                particleController.FireFromPositionNetworked(GunFlashLocation.position);
            }
        }
        ResetAnimationTriggers();
        m_IsAttacking = true;
        AmmoAmount--;
    }
Beispiel #16
0
    // Update is called once per frame
    void Update()
    {
        // Set the colour
        GetComponentInChildren<SpriteRenderer>().material.color = chestColour;

        // If the pickup has been collected
        if (chestOpened && !completed)
        {
            if (onChestOpened != null)
                onChestOpened.Invoke(gameObject);

            // Play sfx
            questManager.PlaySFX();
            ParticleSystemController.InstaniateParticleSystem(collectable, transform.position, Quaternion.identity);

            // Chest opened
            completed = true;
        }
    }
Beispiel #17
0
    // Update is called once per frame
    void Update()
    {
        // Rotate the pickup
        transform.Rotate(Vector3.back * (rotationSpeed * Time.deltaTime));

        // If the pickup has been collected
        if (healthCollected)
        {
            // Health has been collectd
            gameController.HealthCollected();

            // Play sfx
            questManager.PlaySFX();
            ParticleSystemController.InstaniateParticleSystem(collectable, transform.position, Quaternion.identity);

            // Destory the pickup
            Destroy(gameObject);
        }
    }
Beispiel #18
0
    void Start()
    {
        //add width of the lasers to a list and sets the width to 0
        for (int i = 0; i < lineRenderers.Count; i++)
        {
            lrWidth.Add(lineRenderers[i].widthMultiplier);
            lineRenderers [i].widthMultiplier = 0;
            lineRenderers [i].enabled         = false;
        }

        //COLOR - changes color according to ParticleSystemController
        psCtrl = GetComponent <ParticleSystemController>();
        if (psCtrl != null && psCtrl.changeColor)
        {
            for (int i = 0; i < lineRenderers.Count; i++)
            {
                lineRenderers [i].colorGradient = psCtrl.ChangeGradientColor(lineRenderers [i].colorGradient, psCtrl.newMaxColor);
            }
        }

        //add particle systems to a respective list
        if (endVFX != null)
        {
            endVFX.SetActive(false);
            AddPSToList(endVFX, psEndVFX, true);
        }
        if (psVFX != null)
        {
            psVFX.SetActive(false);
            AddPSToList(psVFX, psChilds, true);
        }
        if (trailVFX != null && trail)
        {
            psTrailVFX = trailVFX.GetComponent <ParticleSystem> ();
        }

        //if the end point is a camera the get componenet
        if (endPoint != null)
        {
            cam = endPoint.GetComponent <Camera> ();
        }
    }
Beispiel #19
0
    // Update is called once per frame
    void Update()
    {
        // Rotate the pickup
        transform.Rotate(Vector3.back * (rotationSpeed * Time.deltaTime));

        // If the pickup has been collected
        if (pickupCollected)
        {
            // Call back
            if (onPickupCollected != null)
            {
                onPickupCollected.Invoke(gameObject);
            }

            // Play sfx
            questManager.PlaySFX();
            ParticleSystemController.InstaniateParticleSystem(collectable, transform.position, Quaternion.identity);

            // Destory the pickup
            Destroy(gameObject);
        }
    }
Beispiel #20
0
    // OnTriggerEnter is called when the Collider other enters the trigger
    void OnTriggerStay(Collider other)
    {
        // If the other collider is the player
        if (other.gameObject.tag == Tags.playerTag)
        {
            // If the player presses action saves civillian
            if (other.gameObject.GetComponent <PlayerController>().IsAction())
            {
                // Set the civillian stats
                GameDataManager.instance.SetCivillianStats(transform.position, false, true);

                // Add the civillian to the hud
                hud.AddCivillian(civillianHUDItem);

                // Play sound fx and particles - destroy gameobject
                questManager.PlaySFX();
                ParticleSystemController.InstaniateParticleSystem(savedCivillian, transform.position, Quaternion.identity);
                Destroy(gameObject);
            }

            // Player kills civillian
            else if (other.gameObject.GetComponent <PlayerController>().IsDiggingAttacking())
            {
                // Set the civillian stats
                GameDataManager.instance.SetCivillianStats(transform.position, true, false);

                // Set the rotation
                Quaternion rotation = Quaternion.identity;
                rotation.eulerAngles = new Vector3(0.0f, 0.0f, 90.0f);

                // Play sound fx and particles - destroy gameobject
                questManager.PlaySFX(killedClip);
                ParticleSystemController.InstaniateParticleSystem(killedCivillian, transform.position, rotation);
                Destroy(gameObject);
            }
        }
    }
Beispiel #21
0
    // Check if explosion destroys rocks
    void DestroyGridCubes()
    {
        // Loop through all cubes in the cubes list
        foreach (GameObject cube in cubes)
        {
            // Check that there are cubes
            if (cubes.Count > 0 && cube != null)
            {
                // Get the cube data
                CubeData cubeData = cube.GetComponent <CubeData>();

                // If the cube can be destroyed
                if (cubeData.CubeDestructible())
                {
                    cubeData.CubeDamaged(cubeData.CurrentHealth());
                }
            }
        }

        // If there are cubes in the cubes list
        if (cubes.Count > 0)
        {
            // Loop through each cube
            for (int i = 0; i < cubes.Count; i++)
            {
                // If the cube has been destroyed remove it from the cubes list
                if (cubes[i] == null || cubes[i].GetComponent <CubeData>().CubeDestroyed())
                {
                    cubes.Remove(cubes[i].gameObject);
                }
            }
        }

        // Play the particles
        ParticleSystemController.InstaniateParticleSystem(explosion, transform.position, Quaternion.identity);
    }
Beispiel #22
0
 void Start()
 {
     particleSystemController = particle.GetComponent <ParticleSystemController>();
     buttonUpdate.onClick     = new Button.ButtonClickedEvent();
     buttonUpdate.onClick.AddListener(() => clickUpdate());
 }
Beispiel #23
0
 protected virtual void Awake()
 {
     ParticleController = GetComponent <ParticleSystemController>();
 }
Beispiel #24
0
 public ParticleSystemEndsPlayingEvent(ParticleSystemController particleSystemController)
 {
     ParticleSystemController = particleSystemController;
 }
Beispiel #25
0
 private void UnsubscribeEvents(ParticleSystemController controller)
 {
     controller.Events.RemoveListener(OnParticleEndsPlaying, ParticleSystemEndsPlayingEvent.EVENT_TYPE);
 }
Beispiel #26
0
 // Use this for initialization
 void Start()
 {
     instance = this;
 }
    // Update is called once per frame
    public void HealthUpdate()
    {
        // If the monster has no health
        if (currentHealth == 0)
        {
            // If the monster has no health (not given dead status yet)
            if (!monsterDead)
            {
                // Play the death particles
                monsterController.playerController.AddToScore(pointsScore);

                // If the monster is a basic monster record the monster kill position
                if (monsterController.monsterType == MONSTERTYPE.BASIC)
                {
                    // Killed in quest flag
                    bool killedInQuest;

                    // Is the monster killed during quest
                    if (questManager.MonsterQuest())
                    {
                        killedInQuest = true;
                    }
                    else
                    {
                        killedInQuest = false;
                    }

                    // Record themonster killed
                    GameDataManager.instance.MonsterKilled(MONSTERTYPE.BASIC, monsterController.Index(), transform.position, killedInQuest);
                }

                // If the monsters is a juicy monster record the monster kill position
                if (monsterController.monsterType == MONSTERTYPE.JUICY)
                {
                    // Killed in quest flag
                    bool killedInQuest;

                    // Is the monster killed during quest
                    if (questManager.MonsterQuest())
                    {
                        killedInQuest = true;
                    }
                    else
                    {
                        killedInQuest = false;
                    }

                    // Record themonster killed
                    GameDataManager.instance.MonsterKilled(MONSTERTYPE.JUICY, monsterController.Index(), transform.position, killedInQuest);

                    // Play the juicy particle death
                    ParticleSystemController.InstaniateParticleSystem(monsterController.destroyedSystem, transform.position, Quaternion.identity);
                }
            }

            // The monster is dead
            monsterDead = true;

            // If the monster is a basic monster shrink it on death
            if (monsterController.monsterType == MONSTERTYPE.BASIC)
            {
                // Shrink the monster
                transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(targetScale, targetScale, targetScale), Time.deltaTime * shrinkSpeed);
                Destroy(bodyShadow);
                monsterController.characterController.enabled = false;
                deathTimer -= Time.deltaTime;
            }

            // If the monster is a juicy monster disable sprite
            else if (monsterController.monsterType == MONSTERTYPE.JUICY)
            {
                GetComponentInChildren <SpriteRenderer>().enabled = false;
                Destroy(bodyShadow);
                monsterController.characterController.enabled = false;
                deathTimer -= Time.deltaTime;
            }

            // When the monster has finished dying
            if (deathTimer <= 0.0f)
            {
                // Monster quest
                if (questManager.MonsterQuest() && questManager.MonstersKilled() < questManager.TotalMonsters())
                {
                    if (onMonsterKilled != null)
                    {
                        onMonsterKilled.Invoke(gameObject);
                    }
                }

                // Destroy the gameobject
                Destroy(gameObject);

                // Spawn new monster
                monsterManager.SpawnMonster(monsterManager.monsterHealth);
            }
        }
    }