Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     rb            = GetComponent <Rigidbody>();
     endManager    = FindObjectOfType <EndManager>();
     audioPlayer   = FindObjectOfType <AudioPlayer>();
     eggController = FindObjectOfType <EggController>();
 }
Esempio n. 2
0
    IEnumerator EggHitDetection()
    {
        while (true)
        {
            Collider[] hitColliders = Physics.OverlapSphere(transform.position, m_RadiusEggPicker, m_LayerMask);

            if (hitColliders.Length > 0)
            {
                if (!hitColliders[0].gameObject.GetComponent <EggController>().IsTaken&&
                    !hitColliders[0].gameObject.GetComponent <EggController>().NotUsable &&
                    characterState == CharacterState.withoutEgg)
                {
                    m_EggController = hitColliders[0].gameObject.GetComponent <EggController>();
                    m_EggController.transform.SetParent(m_EggParent);
                    m_EggController.transform.localPosition = m_EggBeginPosition;
                    m_EggController.transform.localRotation = m_BeginRotation;

                    characterState = CharacterState.withEgg;
                    m_EggController.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                    m_EggController.GetComponent <Rigidbody>().useGravity  = false;
                    m_EggController.IsTaken = true;
                }
            }

            yield return(null);
        }
    }
Esempio n. 3
0
 void _makeInstance()
 {
     if (instance != null)
     {
         instance = this;
     }
 }
Esempio n. 4
0
 void Start()
 {
     this.player   = GetComponent <Player>();
     this.rb       = GetComponent <Rigidbody> ();
     this.egg      = GetComponent <EggController>();
     this.playerId = this.player.Id;
 }
Esempio n. 5
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();
    }
Esempio n. 6
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();
    }
Esempio n. 7
0
    public void RemoveEgg(EggController egg)
    {
        if (!m_EggControllers.Remove(egg))
        {
            return;
        }
        float zPosition = egg.transform.position.z;

        if (m_EggControllers.Count == 0)
        {
            GameObject eggGo         = Instantiate(EggPrefab);
            Vector3    spawnPosition = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, zPosition);
            eggGo.transform.position = spawnPosition;

            eggGo.GetComponent <EggController>().IsTaken = false;
            eggGo.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionZ;
            eggGo.GetComponent <Rigidbody>().useGravity  = true;

            AddEgg(eggGo.GetComponent <EggController>());
        }
    }
Esempio n. 8
0
    private IEnumerator MateAsync()
    {
        AudioManager.Instance.PlaySound(_mateSound);

        yield return(new WaitForSeconds(3.0f));

        if (_currentMate != null)
        {
            EggController egg = Instantiate(_eggPrefab);
            egg.transform.position = (transform.position + _currentMate.transform.position) / 2;
            egg.transform.rotation = Random.rotationUniform;

            // Mix the DNA from the two parents and store in the child
            CreatureDescriptor childDNA = CreatureDescriptor.CreateCreatureDescriptorFromParents(this, _currentMate);
            egg.SetDNA(childDNA);

            _currentMate.StopMating();
        }

        StopMating();
    }
Esempio n. 9
0
 public void AddEgg(EggController egg)
 {
     m_EggControllers.Add(egg);
 }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     rb        = GetComponent <Rigidbody>();
     eggScript = GetComponent <EggController>();
 }