Exemplo n.º 1
0
    IEnumerator Co_Chirp()
    {
        yield return(new WaitForSeconds(Random.Range(0.1f, 0.2f) / 2));

        StaticHelpers.GetOrCreateCachedAudioSource(Player.GetClipForAnimal(CurrentAnimal), transform, Random.Range(0.8f, 1.2f), 0.5f);
        GetComponentInChildren <Punchable>().Punch();

        GameObject par = StaticHelpers.SpawnPrefab("Particles/ChirpParticle", 1);

        par.transform.SetParent(transform);
        par.transform.position    = transform.position;
        par.transform.eulerAngles = transform.eulerAngles;
        par.transform.localScale  = Vector3.one;

        if (LocalOwned)
        {
            foreach (Heck.ChallengeRacket challenge in Heck.UnlockManager.GetAll(typeof(Heck.ChallengeRacket)))
            {
                challenge.OnChirp(LocalPlayer.Instance.Player);
            }
        }

        yield return(new WaitForSeconds(Random.Range(0.1f, 0.2f) / 2));

        if (Followee != null)
        {
            Followee.Chirp();
        }
    }
Exemplo n.º 2
0
    protected override void Die()
    {
        if (!Killed)
        {
            base.Die();

            // Explode
            GetComponentInChildren <Animator>().SetTrigger("Die");
            GetComponent <Collider>().isTrigger = true;
            StaticHelpers.GetOrCreateCachedAudioSource("crawler_die", transform.position, Random.Range(0.8f, 1.2f));
            //GameObject death = Instantiate( Resources.Load( "Prefabs/Crawler Death" ), Game.RuntimeParent ) as GameObject;
            //death.transform.position = transform.position;
            //death.transform.rotation = transform.rotation;
            //Destroy( death, 1 );

            // TODO TEMP spawn new replacement
            //Game.Instance.SpawnEnemy( Resources.Load( "Prefabs/Crawler" ) as GameObject );

            // Communicate with Game
            Game.Instance.OnEnemyKilled(this);

            // Delay particle system destruction until trail disappears completely
            var obj = GetComponentInChildren <ParticleSystem>().gameObject;
            obj.transform.parent = Game.RuntimeParent;
            Destroy(obj, 4);

            // Destroy npc
            //gameObject.SetActive( false );
            this.enabled = false;
            Destroy(gameObject, KillDelay);
            Killed = true;
        }
    }
Exemplo n.º 3
0
 public float AddGold(int add)
 {
     Data.Gold = Mathf.Max(0, Data.Gold + add);
     StaticHelpers.GetOrCreateCachedAudioSource("gold_collect", false, Random.Range(0.8f, 1.2f));
     UpdateGoldBag(add);
     return(Data.Gold);
 }
Exemplo n.º 4
0
    void Start()
    {
        part            = GetComponent <ParticleSystem>();
        collisionEvents = new List <ParticleCollisionEvent>();

        StaticHelpers.GetOrCreateCachedAudioSource(OnCreate, transform.position, Random.Range(0.8f, 1.2f), 1);
    }
Exemplo n.º 5
0
 public void Flap()
 {
     if (!Follower)
     {
         StaticHelpers.GetOrCreateCachedAudioSource("flap" + Random.Range(1, 4), transform, Random.Range(0.8f, 1.2f), 0.5f);
     }
 }
Exemplo n.º 6
0
    public void Lose()
    {
        SwitchState(State.MatchToLobbyAnim);
        HUDMessage.text = "Mission failed...";
        Won             = false;

        StaticHelpers.GetOrCreateCachedAudioSource("lose", true);
    }
Exemplo n.º 7
0
    private void Jump()
    {
        Animator.SetTrigger("Jump");
        SwitchState(State.Jump);

        StaticHelpers.GetOrCreateCachedAudioSource(JumpClip, transform.position, Random.Range(0.8f, 1.2f), 0.5f);
        StaticHelpers.EmitParticleDust(transform.position);
    }
Exemplo n.º 8
0
    void SendEffect(Vector3 pos)
    {
        // Effects
        StaticHelpers.GetOrCreateCachedAudioSource("boing", LocalPlayer.Instance.Player.transform, Random.Range(0.8f, 1.2f), 1, 0, true);
        GameObject par = StaticHelpers.EmitParticleDust(pos);

        par.transform.localScale *= 2;
        Punch.Punch();
    }
Exemplo n.º 9
0
    public override void Attack()
    {
        base.Attack();

        GetComponentInChildren <Animator>().SetTrigger("Attack");
        StaticHelpers.GetOrCreateCachedAudioSource("skeleton_attack", transform.position, Random.Range(0.8f, 1.2f));

        Hitbox.Spawn(false, Damage, transform.position + transform.up * 1 + transform.forward * 1, transform.rotation, transform.localScale);
    }
Exemplo n.º 10
0
    public void Win()
    {
        SwitchState(State.MatchToLobbyAnim);
        HUDMessage.text = "Mission success!";
        Won             = true;
        Player.Instance.AddGold(10);

        StaticHelpers.GetOrCreateCachedAudioSource("win", true);
    }
Exemplo n.º 11
0
    private void Attack()
    {
        AttackAnim = !AttackAnim;
        Animator.SetTrigger("Attack" + (AttackAnim ? 1 : 3));            // + Mathf.RoundToInt( Random.Range( 1, 3 ) ) );
        SwitchState(State.Attack);

        float pitch = Random.Range(0.8f, 1.2f);

        StaticHelpers.GetOrCreateCachedAudioSource(SwordClip, Camera.main.transform.position, pitch, 1);
    }
Exemplo n.º 12
0
    public void Open()
    {
        if (OpenTime != -1)
        {
            return;
        }

        OpenTime = Time.time;

        StaticHelpers.GetOrCreateCachedAudioSource(OpenClip, Lid.position, Random.Range(0.8f, 1.2f), Random.Range(0.8f, 1));
    }
Exemplo n.º 13
0
    private void OnGrounded()
    {
        Animator.SetFloat("FallSpeed", 0);

        // If landed after a while of air time, play effects
        if (CurrentStateTime > 0.1f)
        {
            StaticHelpers.EmitParticleDust(transform.position);
            StaticHelpers.GetOrCreateCachedAudioSource("player_land", transform.position, Random.Range(0.8f, 1.2f), 0.5f);
        }
    }
Exemplo n.º 14
0
    private void ButtonClickBuyListing(GameObject listing, BaseItem item)
    {
        if (Player.Instance.HasGold(item.Cost))
        {
            Player.Instance.AddGold(-item.Cost);
            Player.Instance.AddItem(item);

            StaticHelpers.GetOrCreateCachedAudioSource("gold_spend", false, Random.Range(0.8f, 1.2f));

            Destroy(listing);
        }
    }
Exemplo n.º 15
0
    public override void OnHit(Collider other)
    {
        base.OnHit(other);

        if (!Dead)
        {
            Animator.SetTrigger("TakeDamage");
            Game.ChromAb.intensity.value = 1;
            Game.LensDis.intensity.value = -0.2f;

            StaticHelpers.GetOrCreateCachedAudioSource("player_hurt", transform.position, Random.Range(0.8f, 1.2f));
        }
    }
Exemplo n.º 16
0
    public void Hit(Transform other)
    {
        HasHit.Add(other);

        // First hit of players always makes a noise
        if (HasHit.Count == 1 && PlayerTeam == true)
        {
            StaticHelpers.GetOrCreateCachedAudioSource("skeleton_attack", transform.position, Random.Range(0.8f, 1.2f));
        }

        // Only hit one thing per?
        transform.position = Vector3.one * 1000;
        gameObject.SetActive(false);
    }
Exemplo n.º 17
0
    public void OnDrag(DragItem item)
    {
        // Store correct slot if removed from Equipped
        var listing = Listings[item.gameObject];
        var slot    = listing.Element.GetComponentInParent <EquipSlot>();

        if (slot != null)
        {
            listing.EquippedIn        = slot.AcceptsItemType.ToString();
            Listings[item.gameObject] = listing;
        }

        StaticHelpers.GetOrCreateCachedAudioSource("ui_drag", true, Random.Range(0.8f, 1.2f));
    }
Exemplo n.º 18
0
    public void OnTriggerEnter(Collider other)
    {
        bool isplayer = (other.transform == Player.Instance.transform);
        bool noteam   = !isplayer && !other.GetComponent <BaseEnemy>();

        if (!HasHit && ((PlayerTeam != isplayer) || noteam))
        {
            Hit(other);
            HasHit = true;

            StaticHelpers.GetOrCreateCachedAudioSource(HitClip, transform.position, Random.Range(0.8f, 1.2f));

            Destroy(gameObject);
        }
    }
Exemplo n.º 19
0
    public override void Attack()
    {
        base.Attack();

        GetComponentInChildren <Animator>().SetTrigger("Attack");
        StaticHelpers.GetOrCreateCachedAudioSource("slimer_attack", transform.position, Random.Range(0.8f, 1.2f));

        // Spawn projectile
        GameObject projectile = Instantiate(Resources.Load("Prefabs/SlimerProjectile"), Game.RuntimeParent) as GameObject;

        projectile.transform.position = Animator.transform.position + Animator.transform.up * 0.5f;
        projectile.transform.LookAt(Player.Instance.transform.Find("CenterMass"));
        projectile.GetComponent <BaseProjectile>().PlayerTeam = false;
        projectile.GetComponent <BaseProjectile>().Damage     = Damage;
        Destroy(projectile, 5);
    }
Exemplo n.º 20
0
    public bool SwitchLobbyState(LobbyState state, bool first = false, bool force = false)
    {
        if (SwitchLobbyTime != 0 && !force)
        {
            return(false);
        }

        FinishLobbyState(CurrentLobbyState);
        CurrentLobbyState = state;
        StartLobbyState(CurrentLobbyState, first);

        OnLoad();
        StaticHelpers.GetOrCreateCachedAudioSource("ui_swoosh", true, Random.Range(0.8f, 1.2f));

        return(true);
    }
Exemplo n.º 21
0
        IEnumerator Co_Scoreout()
        {
            StaticHelpers.GetOrCreateCachedAudioSource("scoreout", LocalPlayer.Instance.Player.transform, 1, 1, 0, true);

            // UI
            var score = ClipboardItems[JustUnlocked].transform.GetChild(0);

            score.gameObject.SetActive(true);
            var text   = score.GetComponent <Text>();
            var length = text.text.Length;

            text.text = "";
            var between = 0.2f / length;

            for (int i = 0; i < length; i++)
            {
                text.text += "-";
                yield return(new WaitForSeconds(between));
            }
        }
Exemplo n.º 22
0
    void SendChirp(bool addfollower)
    {
        // Sound
        StaticHelpers.GetOrCreateCachedAudioSource(GetClipForAnimal(CurrentAnimal), transform, Random.Range(0.8f, 1.2f), 1, 0, true);
        if (Followee != null)
        {
            Followee.Chirp();
        }

        GameObject par = StaticHelpers.SpawnPrefab("Particles/ChirpParticle", 1);

        par.transform.position    = transform.position;
        par.transform.eulerAngles = transform.eulerAngles;

        GetComponentInChildren <Punchable>().Punch();

        foreach (Heck.ChallengeRacket challenge in Heck.UnlockManager.GetAll(typeof(Heck.ChallengeRacket)))
        {
            challenge.OnChirp(this);
        }
    }
Exemplo n.º 23
0
    // Called from Animator Events
    public void Step()
    {
        Left = !Left;

        bool grounded = true;

        if (Player != null)
        {
            grounded = Player.Grounded;
        }
        if (grounded)
        {
            int     index = Left ? 0 : 1;
            Vector2 pitch = Left ? PitchA : PitchB;
            StaticHelpers.GetOrCreateCachedAudioSource(Clip, Feet[index].position, Random.Range(pitch.x, pitch.y), Random.Range(Volume.x, Volume.y));
            var dust = StaticHelpers.EmitParticleImpact(Feet[index].position);
            if (dust != null)
            {
                dust.transform.localScale = Vector3.one * 0.2f;
            }
        }
    }
Exemplo n.º 24
0
    public void ChirpLocal(bool force = false)
    {
        if (Game.Instance.CurrentState != Game.State.Play && !force)
        {
            return;
        }

        // Sound
        StaticHelpers.GetOrCreateCachedAudioSource(GetClipForAnimal(CurrentAnimal), transform, Random.Range(0.8f, 1.2f), 1, 0, true);
        if (Followee != null)
        {
            Followee.Chirp();
        }

        GameObject par = StaticHelpers.SpawnPrefab("Particles/ChirpParticle", 1);

        par.transform.position    = transform.position;
        par.transform.eulerAngles = transform.eulerAngles;

        GetComponentInChildren <Punchable>().Punch();

        foreach (Heck.ChallengeRacket challenge in Heck.UnlockManager.GetAll(typeof(Heck.ChallengeRacket)))
        {
            challenge.OnChirp(this);
        }

        // Check for close objects with tags
        GameObject obj = FindClosestEnemy();

        if (obj != null)
        {
            // Delete object,
            Vector3 pos = obj.transform.position;
            Destroy(obj);

            PhotonView.RPC("SendSpawnFollower", PhotonTargets.All, pos, CurrentAnimal, photonView.viewID);
        }
        Chirp(obj != null);
    }
Exemplo n.º 25
0
 protected void OnDrop()
 {
     StaticHelpers.GetOrCreateCachedAudioSource("ui_drop", true, Random.Range(0.8f, 1.2f));
 }
Exemplo n.º 26
0
 public void Footstep()
 {
     StaticHelpers.GetOrCreateCachedAudioSource("footstep", transform, Random.Range(0.8f, 1.2f), Follower ? 0.1f : 0.2f, 0, !Follower);
 }