示例#1
0
 // Use this for initialization
 void Start()
 {
     _rigid = GetComponent<Rigidbody> ();
     _input = GetComponent<OnlinePlayerInput> ();
 }
示例#2
0
    // Use this for initialization
    void Start()
    {
        objRigidBody = GetComponent<Rigidbody>();
        objBounds = GetComponent<Collider>().bounds;
        cannonBallPrefab = (GameObject)Resources.Load("CannonBallPrefab");
        onlineInput = GetComponent<OnlinePlayerInput>();

        SetupCamera ();
    }
示例#3
0
    void Start()
    {
        onlineRef = GameObject.Find("OnlineSceneReferences").GetComponent<OnlineSceneReferences>();
        shipAttributes = GetComponent<ShipAttributesOnline>();
        objRigidBody = GetComponent<Rigidbody>();

        //Store initial position and rotation
        Vector3 initialPosition = transform.position;
        Quaternion initialRotation = transform.rotation;
        //Reset object's position and rotation
        transform.position = Vector3.zero;
        transform.rotation = Quaternion.identity;

        objBounds = GetComponent<Collider>().bounds;

        //Set initial position and rotation back
        transform.position = initialPosition;
        transform.rotation = initialRotation;

        onlineInput = GetComponent<OnlinePlayerInput>();
        customOnlinePlayer = GetComponent<CustomOnlinePlayer>();
        playerRespawn = GetComponent<PlayerRespawn>();

        rightCannons = rightSide.GetComponent<CannonGroup>();
        leftCannons = leftSide.GetComponent<CannonGroup>();
        rightLR = rightSide.GetComponent<LineRenderer>();
        leftLR = leftSide.GetComponent<LineRenderer>();

        SetupCamera();

        SetupControls();

        ResetShootAndMovement();
    }
示例#4
0
 void SetupControls()
 {
     onlinePlayerInput = GetComponent<OnlinePlayerInput>();
     onlinePlayerInput.OnServerReceiveRawInput += ChangeAmmoType;
     onlinePlayerInput.OnServerReceiveRawInput += HandleShootInput;
 }
示例#5
0
    /// <summary>
    /// shooting input handling
    /// </summary>
    /// <param name="m"></param>
    /// <param name="dir"></param>
    private void HandleShootInput(OnlinePlayerInput.PlayerControlMessage m, Vector3 dir)
    {
        if (playerRespawn.IsDead || frozen)
            return;

        if (currentProjIndex == 2)
        {
            if (m == OnlinePlayerInput.PlayerControlMessage.SHOOT_START_HOLD_DOWN && currentShootInputState == ShootInputState.Idle)
            {
                currentShootInputState = ShootInputState.Ready;
                return;
            }
            if (m == OnlinePlayerInput.PlayerControlMessage.SHOOT_RELEASE && currentShootInputState == ShootInputState.Ready)
            {
                currentShootInputState = ShootInputState.Idle;
                Shoot(null, 0f);
            }
        }
        else
        {
            if (m == OnlinePlayerInput.PlayerControlMessage.SHOOT_START_HOLD_DOWN && currentShootInputState == ShootInputState.Idle)
            {
                currentShootInputState = ShootInputState.Ready;

                return;
            }
            if (m == OnlinePlayerInput.PlayerControlMessage.SHOOT_RELEASE && currentShootInputState == ShootInputState.Ready)
            {
                currentShootInputState = ShootInputState.Idle;

                activeSide = (Vector3.Dot(dir, leftSide.forward) > 0f) ? leftSide : rightSide;
                activeCannons = activeSide.GetComponent<CannonGroup>();

                if (activeSide == leftSide)
                {
                    Shoot(leftSide, shotPowerLeft);
                    shotPowerLeft = 0f;
                }
                else
                {
                    Shoot(rightSide, shotPowerRight);
                    shotPowerRight = 0f;
                }

                return;
            }
        }

        if (m == OnlinePlayerInput.PlayerControlMessage.CANCEL_START_HOLD && currentShootInputState == ShootInputState.Ready)
        {
            currentShootInputState = ShootInputState.Idle;
            return;
        }
    }
示例#6
0
    /// <summary>
    /// change ammo type
    /// </summary>
    /// <param name="m"></param>
    /// <param name="dir"></param>
    private void ChangeAmmoType(OnlinePlayerInput.PlayerControlMessage m, Vector3 dir)
    {
        if (m == OnlinePlayerInput.PlayerControlMessage.SWITCH_START_HOLD_DOWN)
        {
            currentProjIndex++;

            if (currentProjIndex > projectiles.Count - 1)
                currentProjIndex = 0;
        }
    }