예제 #1
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();
    }
예제 #2
0
    private void CheckSide(Vector3 camVec)
    {
        Transform newActiveSide = null;

        if (Vector3.Angle(camVec, rightSide.forward) < Vector3.Angle(camVec, leftSide.forward))
            newActiveSide = rightSide;
        else
            newActiveSide = leftSide;

        if (newActiveSide != activeSide)
        {
            shotPower = 0f;
        }

        activeSide = newActiveSide;
        activeCannons = activeSide.GetComponent<CannonGroup>();
    }
예제 #3
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;
        }
    }