Пример #1
0
    void PickupGhost(Collider other)
    {
        DeathCheck snake = other.GetComponent <DeathCheck>();

        snake.MakeInvincible(12.0f);
        CoinObjective.CheckForObjective((int)CoinObjective.Objective.FIND_POWERUP, 0);
        SoundManager.PlaySound(SoundManager.Sounds.POWERUP);
        GlobalStats.hud.SpawnText("INVINCIBILITY!", transform.position);
    }
Пример #2
0
    //Atempt to kill the player (Won't if incinvincinle).
    void KillPlayer(DeathCheck deathCheck)
    {
        bool died = deathCheck.Die();

        hideWarningText = true;

        //Destroy this object if the player died to it. Don't if invincible.
        if (died || deathCheck.gameObject.GetComponent <Snake>().GetBoosting())
        {
            Explode();
        }
    }
Пример #3
0
 public IEnumerator CR_Death()
 {
     for (int i = 0; i < DeathCheck.pairs.Count - 1; i++)
     {
         BattlePair a = DeathCheck.pairs[i];
         if (!a.isIgnored)
         {
             for (int j = i + 1; j < DeathCheck.pairs.Count; j++)
             {
                 BattlePair b = DeathCheck.pairs[j];
                 if (!b.isIgnored)
                 {
                     if (a.attackee.Equals(b.attacker) || b.attackee.Equals(a.attacker))
                     {
                         b.SetIgnored();
                     }
                 }
             }
         }
     }
     for (int i = 0; i < DeathCheck.pairs.Count; i++)
     {
         BattlePair p = DeathCheck.pairs[i];
         if (!p.isIgnored)
         {
             DeathCheck check = p.attackee.GetComponent <DeathCheck>();
             if (check.isDead)
             {
                 this.playerNetworkView = this.GetComponent <NetworkView>();
                 if (this.playerNetworkView != null)
                 {
                     if (this.playerNetworkView.isMine)
                     {
                         NetworkPlayer[] players = Network.connections;
                         if (players.Length > 0 && p.attackee != null)
                         {
                             Network.RemoveRPCsInGroup(0);
                             Network.Destroy(p.attackee);
                         }
                         else if (p.attackee != null)
                         {
                             Object.Destroy(p.attackee);
                         }
                         DeathCheck.pairs.Remove(p);
                         yield break;
                     }
                 }
             }
         }
         yield return(null);
     }
 }
Пример #4
0
    //Continue game and exit menu.
    void Revive()
    {
        continues--;

        //Hide the coins gradually.
        GlobalStats.hud.DisplayCoins(false);
        GlobalStats.hud.UpdateHUD();

        gameObject.SetActive(false);
        DeathCheck deathCheck = player.GetComponent <DeathCheck>();

        deathCheck.AddLife();
        deathCheck.Respawn();
    }
Пример #5
0
    private void Start()
    {
        gravity = GameProperties.Singleton.BaseGravity;

        pCollider = GetComponent <Collider>();
        if (Singleton != null)
        {
            Destroy(gameObject);
            return;
        }

        Player = GameManager.Singleton.GetPlayerObject();

        Singleton = this;

        fo1 = Player.GetComponent <ForceObject>();

        //first boi enabled
    }
Пример #6
0
    private void Start()
    {
        this.isEnabled = true;
        //NetworkView playerNetworkView = this.GetComponent<NetworkView>();
        //if (playerNetworkView != null && playerNetworkView.isMine) {
        //	this.isEnabled = true;
        //}

        this.attackable = this.GetComponent <Attackable>();
        if (this.attackable == null)
        {
            Debug.LogException(new System.NullReferenceException("Attackable is null."));
        }
        this.deathCheck = this.GetComponent <DeathCheck>();
        if (this.deathCheck == null)
        {
            Debug.LogException(new System.NullReferenceException("Death check is null."));
        }
    }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        scoreText        = scoreObject.GetComponent <Text>();
        requiredFoodText = requiredFoodObject.GetComponent <Text>();
        coinText         = coinObject.GetComponent <Text>();

        bonusMultiplierTime = bonusMultiplierObject.GetComponent <Image>();
        ghostTime           = ghostObject.GetComponent <Image>();
        fireTime            = fireObject.GetComponent <Image>();

        multiplierText = bonusMultiplierObject.transform.GetChild(0).GetChild(0).GetComponent <Text>();

        defaultCoinPosition = coinText.rectTransform.position;

        playerDeathCheck = GameObject.Find("Player").GetComponent <DeathCheck>();
        fireBreathe      = GameObject.Find("Tongue").GetComponent <FireBreathe>();

        DisplayCoins(false);

        HideChildren();
    }
Пример #8
0
    private void AttackEnemies()
    {
        if (this.attackTargetUnits.Count > 0)
        {
            GameObject enemy = this.attackTargetUnits[0];
            if (enemy == null)
            {
                this.attackTargetUnits.RemoveAt(0);
                return;
            }
            Selectable enemySelect = enemy.GetComponent <Selectable>();
            if (enemySelect == null)
            {
                this.attackTargetUnits.RemoveAt(0);
                return;
            }
            if (enemySelect.UUID.Equals(this.selectable.UUID))
            {
                this.attackTargetUnits.RemoveAt(0);
                return;
            }
            DeathCheck check = enemy.GetComponent <DeathCheck>();
            if (check != null && !check.isDead)
            {
                if (Vector3.Distance(enemy.transform.position, this.gameObject.transform.position) <= 2.5f)
                {
                    if (this.gameObject != null && enemy.gameObject != null)
                    {
                        BattlePair p = new BattlePair(this.gameObject, enemy);
                        if (!DeathCheck.pairs.Contains(p))
                        {
                            //TODO: Swap this to another script that keeps track of strength and HP.
                            Attackable attack = enemy.GetComponent <Attackable>();
                            if (attack != null)
                            {
                                if (attack.attackCooldown <= 0f)
                                {
                                    NetworkViewID viewID = enemy.GetComponent <NetworkView>().viewID;
                                    this.attackableNetworkView.RPC("RPC_DecreaseHealth", RPCMode.AllBuffered, viewID);

                                    HealthBar bar = enemy.GetComponent <HealthBar>();
                                    Divisible div = enemy.GetComponent <Divisible>();
                                    if (bar.currentHealth <= 0f || bar.healthPercentage <= 0f || !div.IsDivisibleStateReady())
                                    {
                                        check.Kill();
                                        DeathCheck.pairs.Add(p);
                                    }

                                    attack.attackCooldown = 1.414f;
                                }
                                else
                                {
                                    attack.attackCooldown -= Time.deltaTime;
                                }
                            }
                        }
                    }
                }
                else
                {
                    Vector3 unitVector = (enemy.transform.position - this.gameObject.transform.position).normalized;
                    if (this.attackableNetworkView != null && !this.receivedAttackCommand)
                    {
                        this.receivedAttackCommand = true;
                        this.attackableNetworkView.RPC("RPC_Attack", RPCMode.AllBuffered, this.gameObject.transform.position + unitVector);
                    }
                }
            }
        }
    }