示例#1
0
    // sets the follower camera using a regular camera.
    // this adds a follower component if it doesn't exist.
    // this does NOT change the target display.
    public FollowerCamera SetFollowerCamera(Camera camera)
    {
        // player camera
        if (camera == null)
        {
            return(null);
        }

        // tries to get the camera
        playerCamera = camera.gameObject.GetComponent <FollowerCamera>();

        // if the camera didn't have a follower camera component, add one.
        if (playerCamera == null)
        {
            playerCamera = camera.gameObject.AddComponent <FollowerCamera>();
        }

        camera.tag   = "Camera";
        camera.depth = -1;

        // attaches the camera
        playerCamera.cameraObject = camera;

        // set values
        playerCamera.distance          = cameraDistance;
        playerCamera.target            = gameObject;
        playerCamera.useParentRotation = true;

        return(playerCamera);
    }
示例#2
0
        /// <summary>
        /// Api's reimplementation of <see cref="KillAnimation.CoPerformKill"/><br/>
        /// Shouldn't be used in regular code
        /// </summary>
        public static IEnumerator CoPerformCustomKill(this KillAnimation anim, PlayerControl source, PlayerControl target, CustomMurderOptions options)
        {
            FollowerCamera camera        = Camera.main !.GetComponent <FollowerCamera>();
            bool           isParticipant = source == PlayerControl.LocalPlayer || target == PlayerControl.LocalPlayer;

            KillAnimation.SetMovement(target, false);
            if (isParticipant)
            {
                camera.Locked = true;
            }
            target.Die(DeathReason.Kill);
            DeadBody deadBody = Object.Instantiate(anim.bodyPrefab); // https://github.com/Herysia/AmongUsTryhard
            Vector3  vector   = target.transform.position + anim.BodyOffset;

            vector.z = vector.y / 1000;
            deadBody.transform.position = vector;
            deadBody.ParentId           = target.PlayerId;
            target.SetPlayerMaterialColors(deadBody.GetComponent <Renderer>());
            if (!options.HasFlag(CustomMurderOptions.NoSnap))
            {
                KillAnimation.SetMovement(source, false);
                SpriteAnim sourceAnim = source.GetComponent <SpriteAnim>();
                yield return(new WaitForAnimationFinish(sourceAnim, anim.BlurAnim));

                source.NetTransform.SnapTo(target.transform.position);
                sourceAnim.Play(source.MyPhysics.IdleAnim, 1f);
                KillAnimation.SetMovement(source, true);
            }
            KillAnimation.SetMovement(target, true);
            if (isParticipant)
            {
                camera.Locked = false;
            }
        }
示例#3
0
    public void SetUpCamera(Player player)
    {
        FollowerCamera followerCamera = Camera.main.GetComponent <FollowerCamera>();
        Vector3        position       = followerCamera.transform.position;

        position.x = player.transform.position.x;
        position.y = player.transform.position.y;
        followerCamera.transform.position = position;
        followerCamera.StartFollowing();
    }
示例#4
0
 void Start()
 {
     movement = GetComponent <PlayerMovement>();
     Assert.IsNotNull(movement);
     state = GetComponent <PlayerState>();
     Assert.IsNotNull(state);
     actions = GetComponent <PlayerActions>();
     Assert.IsNotNull(actions);
     fCamera = FindObjectOfType <FollowerCamera>();
     Assert.IsNotNull(fCamera);
 }
示例#5
0
        public static bool Prefix(PolusShipStatus __instance)
        {
            Camera main = Camera.main;

            main.backgroundColor = __instance.CameraColor;
            FollowerCamera component = main.GetComponent <FollowerCamera>();

            DestroyableSingleton <HudManager> .Instance.ShadowQuad.material.SetInt("_Mask", 7);

            if (component)
            {
                component.shakeAmount = 0f;
                component.shakePeriod = 0f;
            }

            return(false);
        }
示例#6
0
    // sets the follower camera
    // this does NOT change the target display.
    public void SetFollowerCamera(FollowerCamera cam)
    {
        // provided camera is null.
        if (cam == null)
        {
            return;
        }

        // attaches the camera
        playerCamera = cam;
        playerCamera.cameraObject = playerCamera.gameObject.GetComponent <Camera>();

        // attaches the camera
        // adds a follower camera script, and gives it the base value.

        playerCamera.distance          = cameraDistance;
        playerCamera.target            = gameObject;
        playerCamera.useParentRotation = true;
    }
示例#7
0
    // gets the follower camera, generating a new one if it doesn't exist.
    public FollowerCamera GetFollowerCamera()
    {
        // player camera
        if (playerCamera != null)
        {
            return(playerCamera);
        }

        // tries to get the camera
        playerCamera = GetComponent <FollowerCamera>();

        // returns the player camera if it's not set.
        if (playerCamera != null)
        {
            return(playerCamera);
        }

        GameObject newCamera = new GameObject("Player " + playerNumber + " Camera");

        newCamera.tag = "Camera";

        Camera camComp = newCamera.AddComponent <Camera>();

        camComp.depth = -1;

        if (playerNumber > 0)
        {
            camComp.targetDisplay = playerNumber;
        }

        // attaches the camera
        // adds a follower camera script, and gives it the base value.
        playerCamera = newCamera.AddComponent <FollowerCamera>();
        playerCamera.cameraObject = camComp;

        playerCamera.distance          = cameraDistance;
        playerCamera.target            = gameObject;
        playerCamera.useParentRotation = true;

        return(playerCamera);
    }
示例#8
0
            private static System.Collections.IEnumerator CoPerformKillFixed(KillAnimation __instance,
                                                                             PlayerControl source, PlayerControl target)
            {
                FollowerCamera cam           = Camera.main.GetComponent <FollowerCamera>();
                bool           isParticipant = PlayerControl.LocalPlayer == source || PlayerControl.LocalPlayer == target;
                PlayerPhysics  sourcePhys    = source.MyPhysics;

                KillAnimation.SetMovement(source, false);
                KillAnimation.SetMovement(target, false);
                if (isParticipant)
                {
                    cam.Locked = true;
                }

                target.Die(DeathReason.Kill);
                //We spawn dead body before WaitForAnimationFinish, to prevent having delay before the body spawns, while the target is already dead
                DeadBody deadBody = Object.Instantiate <DeadBody>(__instance.bodyPrefab);
                Vector3  vector   = target.transform.position + __instance.BodyOffset;

                vector.z = vector.y / 1000f;
                deadBody.transform.position = vector;
                deadBody.ParentId           = target.PlayerId;
                target.SetPlayerMaterialColors(deadBody.GetComponent <Renderer>());
                //
                SpriteAnim sourceAnim = source.GetComponent <SpriteAnim>();

                yield return(new WaitForAnimationFinish(sourceAnim, __instance.BlurAnim));

                source.NetTransform.SnapTo(target.transform.position);
                sourceAnim.Play(sourcePhys.IdleAnim, 1f);
                KillAnimation.SetMovement(source, true);
                //
                KillAnimation.SetMovement(target, true);
                if (isParticipant)
                {
                    cam.Locked = false;
                }

                yield break;
            }
示例#9
0
    // public int;

    // creates the players.
    // if 'useMainCamera' is set to true, then the player uses the main camera (default view). Otherwise a new camera is made.
    // the target display is used to determine which camera to use.
    public PlayerObject CreatePlayer(int number, GameBuilder.playables type, bool controllable, bool destroySaved, bool useMainCamera, int targetDisplay = 0)
    {
        // new player
        GameObject newPlayer;

        // type
        switch (type)
        {
        case GameBuilder.playables.dog:
            newPlayer = Instantiate((GameObject)Resources.Load("Prefabs/Characters/Dog Player"));
            break;

        case GameBuilder.playables.cat:
            newPlayer = Instantiate((GameObject)Resources.Load("Prefabs/Characters/Cat Player"));
            break;

        case GameBuilder.playables.bunny:
            newPlayer = Instantiate((GameObject)Resources.Load("Prefabs/Characters/Bunny Player"));
            break;

        case GameBuilder.playables.turtle:
            newPlayer = Instantiate((GameObject)Resources.Load("Prefabs/Characters/Turtle Player"));
            break;

        case GameBuilder.playables.none:
        default:
            newPlayer = Instantiate((GameObject)Resources.Load("Prefabs/Characters/Player"));
            break;
        }


        // player object values
        PlayerObject px = newPlayer.GetComponent <PlayerObject>();

        number = Mathf.Clamp(number, 0, 4);

        px.SetPlayerNumber(number);
        px.ParentIconToPlayerSpace();

        // px.playerNumber = number;

        // the player is controllable
        px.controllablePlayer = controllable;

        // Player Camera
        {
            // used to check and see if the main camera is available.
            bool mainCamUsed = false;

            // camera objects
            GameObject     camObject = null; // game object
            Camera         camComp   = null; // camera component
            FollowerCamera fwr       = null; // folloer componetn

            // use main camera
            if (useMainCamera)
            {
                camObject = GameObject.Find("Main Camera");

                // finds the cam object.
                if (camObject != null)
                {
                    // gets camera object.
                    camComp = camObject.GetComponent <Camera>();

                    // the camera is not equal to null, which mean the main cam exists.
                    if (camComp != null)
                    {
                        // gets follower camera
                        fwr = camObject.GetComponent <FollowerCamera>();

                        // follower component exists
                        if (fwr != null)
                        {
                            px.SetFollowerCamera(fwr); // sets follower component

                            mainCamUsed = true;        // camera found and used
                        }
                        else
                        {
                            Debug.LogError("Main camera did not have follower component. Generating new camera.");
                        }
                    }
                    else
                    {
                        Debug.LogError("Camera component on Main Camera object not found. Generating new camera.");
                    }
                }
                else
                {
                    Debug.LogError("Main camera object not found. Generating new camera.");
                }
            }

            if (!useMainCamera || !mainCamUsed) // creates another camera specifically for this player
            {
                // gets instance of camera
                camObject = Instantiate((GameObject)Resources.Load("Prefabs/Player Camera"));

                // gets camera component
                camComp = camObject.GetComponent <Camera>();

                // gets follower camera
                fwr = camObject.GetComponent <FollowerCamera>();
                px.SetFollowerCamera(fwr);
            }

            // sets the target display
            // target display defaults to 0.
            if (camComp != null)
            {
                camComp.targetDisplay = targetDisplay;
            }
        }

        // original camera setup
        // // if the number is greater than 0, set the target display to it.
        // if (number > 0 && !useMainCamera)
        // {
        //     // TODO: playerCamera has not been set for some reason.
        //     // camera object.
        //     // it's done this way just in case the follower camera isn't set yet.
        //     Camera cam = px.GetFollowerCamera().GetCamera();
        //
        //     // change target display
        //     if(cam != null)
        //         cam.targetDisplay = number;
        // }
        // else // use main camera
        // {
        //     GameObject camObject = GameObject.Find("Main Camera");
        //     Camera camComp = camObject.GetComponent<Camera>();
        //     FollowerCamera fwr = px.SetFollowerCamera(camComp);
        // }

        // saves the player object
        // also increases player count if no player object was assigned yet.
        switch (number)
        {
        case 1:
        default:
            if (p1 == null)
            {
                playerCount++;
            }

            if (destroySaved)
            {
                Destroy(p1);
            }

            p1 = px;
            break;

        case 2:
            if (p2 == null)
            {
                playerCount++;
            }

            if (destroySaved)
            {
                Destroy(p2);
            }

            p2 = px;
            break;

        case 3:
            if (p3 == null)
            {
                playerCount++;
            }

            if (destroySaved)
            {
                Destroy(p3);
            }

            p3 = px;
            break;

        case 4:
            if (p4 == null)
            {
                playerCount++;
            }

            if (destroySaved)
            {
                Destroy(p4);
            }

            p4 = px;
            break;
        }

        // returns the player object script
        return(px);
    }