Exemplo n.º 1
0
    public void EchoOn(FrogHub hub)
    {
        hub.OnScream();

        EffectHub eh = GameObject.Instantiate(hub.m_spawnedEffect, hub.transform.position, hub.transform.rotation) as EffectHub;

        eh.m_hostFrog = hub;
        eh.OnTrigger();
    }
Exemplo n.º 2
0
    public void OnInit(TileHub host)
    {
//		_host = host;

        _editRenderer.enabled = false;

        CfgFrog fc = host.Prog.GetFrogConfigByIndex(m_frogType);
        FrogHub fh = GameObject.Instantiate(fc.m_prefab, transform) as FrogHub;

        host.State.m_activeFrogs.Add(new FrogController(fh));
    }
Exemplo n.º 3
0
//	private FrogHub _hub;

    public FrogController(FrogHub hub)
    {
//		_hub = hub;
    }
Exemplo n.º 4
0
    public void UpdateFrame(float dt)
    {
        Vector3 mv    = new Vector3(Input.GetAxis(m_horizontalWalk), 0, Input.GetAxis(m_verticalWalk)).normalized;
        Vector3 force = mv + Vector3.up * 1.0f;

        _hub.GetComponent <CharacterController> ().Move(-force * _hub.m_walkSpeed * dt);

        Animator anim = _hub.GetComponent <Animator> ();

        anim.speed = _hub.m_animSpeed;

        if (mv.sqrMagnitude > Mathf.Epsilon)
        {
            _hub.transform.LookAt(_hub.transform.position - mv, Vector3.up);
            anim.SetFloat("walkSpeed", 1.0f);
        }
        else
        {
            anim.SetFloat("walkSpeed", 0.0f);
        }

        if (Input.GetButtonDown(m_interact))
        {
            if (_heldFrog == null)
            {
                // find note
                NoteHub[] _allNotes = GameObject.FindObjectsOfType <NoteHub> ();
                NoteHub   note      = null;
                for (int i = 0; i < _allNotes.Length; ++i)
                {
                    float dist = (_allNotes [i].transform.position - _hub.transform.position).magnitude;
                    if (dist < _allNotes [i].m_triggerRange)
                    {
                        note = _allNotes [i];
                    }
                }

                if (note != null)
                {
                    EffectHub eh = GameObject.Instantiate(note.m_spawnedEffect, note.transform.position, note.transform.rotation) as EffectHub;
                    eh.OnTrigger();

                    if (_source.isPlaying)
                    {
                        _source.Stop();
                    }
                    _source.clip = _hub.m_noteAudio;
                    _source.Play();
                }
                else
                {
                    // find frogs
                    FrogHub[] _allHubs       = GameObject.FindObjectsOfType <FrogHub> ();
                    FrogHub   pickup         = null;
                    float     pickupDistance = 0.0f;

                    for (int i = 0; i < _allHubs.Length; ++i)
                    {
                        float dist = (_allHubs [i].transform.position - _hub.transform.position).magnitude;
                        if (dist < _allHubs [i]._pickupRange && _allHubs [i].m_canPickUp)
                        {
                            if (pickup == null || dist < pickupDistance)
                            {
                                pickup         = _allHubs [i];
                                pickupDistance = dist;
                            }
                        }
                    }

                    if (pickup != null)
                    {
                        _heldFrog = pickup;
                        _heldFrog.transform.SetParent(_hub.m_frogBone);
                        _heldFrog.transform.localPosition = Vector3.zero;
                        _heldFrog.transform.localRotation = Quaternion.identity;
                        _heldFrog.OnPickUp();
                        anim.SetBool("hasFrog", true);
                    }
                }
            }
            else
            {
                Transform ground = _hub.transform.parent;
                _heldFrog.transform.SetParent(ground);
                _heldFrog.transform.position = _hub.transform.position + _hub.transform.forward * 0.1f;
                _heldFrog.transform.rotation = _hub.transform.rotation;
                _heldFrog.OnDrop();
                _heldFrog = null;
                anim.SetBool("hasFrog", false);
            }
        }
    }