示例#1
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
示例#2
0
    void Start()
    {
        _fxFoxBackground = _fxFoxBackground.GetComponent <FoxController> ();
        _fxFoxForeground = _fxFoxForeground.GetComponent <FoxController> ();


        dragDistances = Screen.height * 20 / 100; // dragDistance is 20% heigh of the screen

        Canvas.SetActive(false);
        GameOver.SetActive(false);

        AudioSource source_fxFoxBackground = GetComponent <AudioSource>();
        AudioSource source_fxFoxForeground = GetComponent <AudioSource>();
    }
示例#3
0
    public void GenerateFoxes(List <ChickenController> chickens)
    {
        foreach (ChickenController chick in chickens)
        {
            Debug.Assert(foxSpawnPoint.Count > 0);
            int index = Random.Range(0, foxSpawnPoint.Count);

            Vector3 spawnPosition = foxSpawnPoint[index].transform.position;
            //spawnPosition +=

            GameObject foxObject = Instantiate(this.foxObject, spawnPosition, Quaternion.identity);
            foxList.Add(foxObject);
            FoxController fox = foxObject.GetComponent <FoxController>();
            fox.targetChicken = chick.gameObject;
            fox.state         = FoxController.foxState.chaseChicken;
        }
    }
示例#4
0
    public void RespawnFox(FoxController fox)
    {
        fox.gameObject.transform.position = spawn_fox[(int)checkpoint].position;
        fox.Heal(10);

        GameObject e = GameObject.FindWithTag("Egg");

        e.transform.position = spawn_egg[(int)checkpoint].position;
        EggController egg = e.GetComponent <EggController>();

        egg.Heal(10);
        if (egg.CheckCountdown())
        {
            egg.SwitchSides();
        }

        GameObject cam = GameObject.FindWithTag("MainCamera");

        cam.GetComponent <CameraFollow>().Respawn();
    }
示例#5
0
    public void RespawnEgg(EggController egg)
    {
        egg.gameObject.transform.position = spawn_egg[(int)checkpoint].position;
        egg.Heal(10);

        GameObject f = GameObject.FindWithTag("Fox");

        f.transform.position = spawn_fox[(int)checkpoint].position;
        FoxController fox = f.GetComponent <FoxController>();

        fox.Heal(10);
        if (fox.CheckCountdown())
        {
            fox.SwitchSides();
        }

        GameObject cam = GameObject.FindWithTag("MainCamera");

        cam.GetComponent <CameraFollow>().Respawn();
    }
示例#6
0
 // Use this for initialization
 void Start()
 {
     player = gameObject.GetComponentInParent <FoxController> ();
 }
示例#7
0
    IEnumerator WaitForDestroy(FoxController e)
    {
        yield return(new WaitForSeconds(e.timeDestroy));

        e.destructor = true;
    }
示例#8
0
 // Use this for initialization
 void Start()
 {
     player = gameObject.GetComponentInParent<FoxController> ();
 }
示例#9
0
    // Triggers when the weapon/attack-collider collides with an enemy player character.
    // We are the attacker, while the enemy is the victim.
    public void OnTriggerEnter(Collider other)
    {
        PlayerInformation attackerInfo = owner.GetComponent <PlayerInformation>();
        PlayerInformation victimInfo   = other.GetComponent <PlayerInformation>();
        int          attackerID        = (attackerInfo != null ? attackerInfo.ConnectionID : -1);
        int          victimID          = (victimInfo != null ? victimInfo.ConnectionID   : -1);
        PlayerHealth victimHealth      = other.GetComponent <PlayerHealth>();

        // PLAYER VS. ENEMY
        if (other.gameObject.tag == "Enemy")
        {
            if ((attackerID < 0) || (victimID < 0) || (victimHealth == null) || !other.transform.GetChild(1).gameObject.activeInHierarchy)
            {
                return;
            }

            // BIRD
            if (this.gameObject.tag == "pecker")
            {
                pecker birdPecker = this.GetComponent <pecker>();

                if (birdPecker != null)
                {
                    victimHealth.Attack(birdPecker.GetDamage(), owner, attackerID, victimID, other.gameObject.transform.position);
                }
                // BUNNY
            }
            else if (this.gameObject.tag == "projectile")
            {
                BunnyPoop bunnyPoop = this.GetComponent <BunnyPoop>();

                if (bunnyPoop != null)
                {
                    victimHealth.Attack(bunnyPoop.GetDamage(), owner, attackerID, victimID, other.gameObject.transform.position);
                }

                NetworkServer.Destroy(this.gameObject);
                // FOX
            }
            else if ((this.gameObject.tag == "foxbite") && (other.gameObject.tag == "Enemy"))
            {
                FoxController foxCtrl = owner.GetComponent <FoxController>();

                if (foxCtrl != null)
                {
                    victimHealth.Attack(foxCtrl.GetDamage(), owner, attackerID, victimID, foxCtrl.biteImpact());
                }
                // MOOSE
            }
            else if ((this.gameObject.tag == "mooseAttack") && (other.gameObject.tag == "Enemy"))
            {
                MooseController mooseCtrl = owner.GetComponent <MooseController>();

                if (mooseCtrl != null)
                {
                    victimHealth.Attack(mooseCtrl.GetDamage(), owner, attackerID, victimID, mooseCtrl.ramImpact());
                }
            }
            // PLAYER VS. NPC
        }
        else if (other.gameObject.tag == "npc")
        {
            PlayerHealth  playerHealth  = owner.GetComponent <PlayerHealth>();
            PlayerEffects playerEffects = owner.GetComponent <PlayerEffects>();
            NPC           npc           = other.GetComponent <NPC>();

            if ((npc == null) || npc.IsDead)
            {
                return;
            }

            npc.IsDead = true;
            playerEffects.CmdBloodParticle(other.transform.position);

            switch (npc.type)
            {
            case "whale":   playerEffects.CmdAddToughness(0.05f);  break;

            case "cat":     playerEffects.CmdAddDamage(0.05f);     break;

            case "dog":     playerEffects.CmdAddSpeed(0.05f);      break;

            case "eagle":   playerEffects.CmdAddJump(0.05f);       break;

            case "chicken": playerHealth.Heal(10.0f);              break;

            default:        Debug.Log("ERROR! Unknown NPC type."); break;
            }

            other.gameObject.GetComponent <NPC>().die();
        }
    }