示例#1
0
    public PlayerController Init()
    {
        inputManager      = GetComponent <GameClasses.InputManager>();
        nutGrabber        = GetComponent <NutGrabber>();
        audioPlayer       = transform.FindChild("AudioPlayer").GetComponent <AudioSource>();
        buttStompAttacker = transform.Find("ButtStompAttacker").GetComponent <ButtStompAttacker>();
        fxSpawner         = GameObject.Find("FXSpawner_" + playerNum).GetComponent <FXSpawner>();

        if (transform.FindChild("AttackBox"))
        {
            attacker    = transform.FindChild("AttackBox").GetComponent <Attacker>();
            topAttacker = transform.FindChild("AttackBox_Top").GetComponent <AttackerTop>();
        }
        else
        {
            Debug.LogWarning("Attacker Not Found!");
        }

        if (transform.FindChild("Particle System"))
        {
            partSys = transform.FindChild("Particle System").GetComponent <ParticleSystem>();
        }
        else
        {
            Debug.LogWarning("Particle System Not Found!");
        }

        if (anim == null)
        {
            Debug.LogError("Link animator");
        }

        speedSet        = speed;
        speedBoostSpeed = speed * 1.6f;
        normScale       = transform.localScale;
        leftScale       = new Vector3(-normScale.x, normScale.y, normScale.z);

        facingRight          = true;
        allowNegativeScaling = true;
        defaultColor         = squirrelGeo.renderer.material.color;

        return(this);
    }
示例#2
0
 //---------------------------------------------------------------------------------- -
 //  On Nut Released Function
 //---------------------------------------------------------------------------------- -
 private void OnNutReleased(NutGrabber nutGrabber)
 {
     m_movementController.SetSpeed(m_speed);
 }
示例#3
0
    //---------------------------------------------------------------------------------- -
    //  On Nut Grabbed Function
    //---------------------------------------------------------------------------------- -
    private void OnNutGrabbed(NutGrabber nutGrabber)
    {
        m_movementController.SetSpeed(m_speed * m_slowMod);

        m_fxSpawner.SpawnEffect(FXType.GrabNut, true);
    }
示例#4
0
    //---------------------------------------------------------------------------------- -
    //  Initialization Function
    //---------------------------------------------------------------------------------- -
    public PlayerController Init(UIManager uiManager)
    {
        //  Registering for events  //
        GameManager.OnNutScored += MaxOutControllerVibration;

        if (m_movementController == null)
        {
            m_movementController = GetComponent <MovementController>();
        }

        if (m_inputController == null)
        {
            m_inputController = GetComponent <InputController>();
        }

        if (m_nutGrabber == null)
        {
            m_nutGrabber = GetComponent <NutGrabber>();
        }

        if (m_audioPlayer == null)
        {
            m_audioPlayer = transform.Find("AudioPlayer").GetComponent <AudioSource>();
        }

        if (m_buttStompAttacker == null)
        {
            m_buttStompAttacker = transform.Find("ButtStompAttacker").GetComponent <ButtStompAttacker>();
        }

        if (m_rigidbody == null)
        {
            m_rigidbody = GetComponent <Rigidbody>();
        }

        if (m_renderer == null)
        {
            m_renderer = squirrelGeo.GetComponent <Renderer>();
        }

        if (m_squeaker == null)
        {
            m_squeaker = GetComponent <SquirrelSqueaker>();
        }

        if (m_collider == null)
        {
            m_collider = GetComponent <CapsuleCollider>();
        }

        m_fxSpawner = Instantiate(m_fxSpawnerPrefab).GetComponent <FXSpawner>();
        //m_fxSpawner = GameObject.Find("FXSpawner_" + m_playerNumber).GetComponent<FXSpawner>();

        if (squirrelGeo == null)
        {
            Debug.LogError("Player geometry is not assigned, assign it before continuing.");
        }

        m_uiManager = uiManager;

        if (transform.FindChild("AttackBox"))
        {
            m_attacker    = transform.FindChild("AttackBox").GetComponent <Attacker>();
            m_attackerTop = transform.FindChild("AttackBox_Top").GetComponent <AttackerTop>();
        }
        else
        {
            Debug.LogWarning("Attacker Not Found!");
        }

        if (transform.FindChild("Particle System"))
        {
            m_particleSystem_DustTrail = transform.FindChild("Particle System").GetComponent <ParticleSystem>();
        }
        else
        {
            Debug.LogWarning("Particle System Not Found!");
        }

        if (m_animator == null)
        {
            Debug.LogError("Link animator");
        }


        m_controlAxes = new Vector2(0, 0);

        allowNegativeScaling = true;

        m_defaultColor = m_renderer.material.color;

        //  Create a UI indicator for this player  //
        m_uiManager.SpawnPlayerMarker(gameObject);

        InitializeComponents();

        //  Log the starting player position so they can respawn if needed  //
        m_startingPlayerPosition = transform.position;

        //  Registering for player events  //
        m_nutGrabber.OnNutGrabberGrabbed  += OnNutGrabbed;
        m_nutGrabber.OnNutGrabberReleased += OnNutReleased;
        m_movementController.OnGrounded   += OnGrounded;
        m_movementController.OnJump       += OnJump;
        m_movementController.OnDoubleJump += OnDoubleJump;

        return(this);
    }