Пример #1
0
 private void Awake()
 {
     playerTransform                = GameObject.FindGameObjectWithTag("Player").transform;
     IsometricCamera.instance       = this;
     IsometricCamera.Camera         = gameObject.GetComponent <Camera>();
     IsometricCamera.StaticDistance = distance;
 }
Пример #2
0
    // Use this for initialization
    void Start()
    {
        if (Camera.main != null)
        {
            cam = Camera.main.transform;
        }

        rigidBody  = GetComponent <Rigidbody> ();
        animator   = GetComponent <Animator>();
        locomotion = new Locomotion(animator);
        isoCam     = Camera.main.GetComponent <IsometricCamera>();

        capsule       = GetComponent <CapsuleCollider>();
        capsuleHeight = capsule.height;
        capsuleCenter = capsule.center;

        //define avatarBones with rigid bodies in player game object

        avatarBones = gameObject.GetComponentsInChildren <Rigidbody>();

        //set avatarBones to is kinematic

        foreach (Rigidbody bone in avatarBones)
        {
            bone.isKinematic = true;
        }

        rigidBody.isKinematic   = false;
        rigidBody.constraints   = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        origGroundCheckDistance = groundCheckDistance;
    }
    void OnObjectMoved( FieldObject obj )
    {
        if( obj.collider.tag == "Player" )
        {
            camScript = obj.collider.GetComponent<IsometricCamera>();

            if( null == camScript )
            {
                Debug.LogError( "Could not find 'IsometricCamera' component attached to object tagged 'Player'" );
                return;
            }

            EaseFn = Interpolate.Ease( EaseType );

            if( null == EaseFn )
            {
                Debug.LogError( "Failed to retrieve Ease function for EaseType '" + EaseType.ToString() + "'" );
                return;
            }

            camScript.Distance = EaseFn( DistanceA, DistanceB-DistanceA, obj.percent, 1.0f );
            camScript.Offset = Interpolate.Ease(EaseFn, OffsetA, OffsetB-OffsetA, obj.percent, 1.0f );
            camScript.Rotation = Interpolate.Ease(EaseFn, RotationA, RotationB-RotationA, obj.percent, 1.0f );
        }
    }
    private void Start()
    {
        // Get the transform of the main camera to allow for camera-relative controls
        if (Camera.main != null)
        {
            cam = Camera.main.transform;
        }
        else
        {
            Debug.LogWarning(
                "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
        }

        // Initialize variables
        character = GetComponent<RobotCharacter>();
		ragdoll = GetComponent<RobotRagdoll>();
		particle = GetComponent<RobotParticleManager>();
		energy = GetComponent<RobotEnergy>();
		isoCam = Camera.main.GetComponent<IsometricCamera>();
		GM = GameObject.Find("GameManager").GetComponent<GameManager>();
		gui = GameObject.Find ("GUI").GetComponentInChildren<GUIManager>();
		entity = GetComponentInChildren<EntityRig>();
		crouch = false;
		guard = false;
		leftTriggerReleased = true;
		rightTriggerReleased = true;
		energy.StartEnergyDrain();
    }
Пример #5
0
        public void CreateWithLookDirection()
        {
            var lookDirection = Vector3D.UnitY;

            camera = new IsometricCamera(Resolve <Device>(), Resolve <Window>(), lookDirection);
            Assert.AreEqual(-lookDirection, camera.Position);
            Assert.AreEqual(Vector3D.Zero, camera.Target);
        }
Пример #6
0
    void Start()
    {
        // 백그라운드의 반지름
        radius = rect_Background.rect.width * 0.5f;

        PlayerScript = GameManager.instance.mainPlayer.GetComponent <Player>();
        PlayerCamera = GameObject.Find("Main Camera").GetComponent <IsometricCamera>();
        go_Player    = GameManager.instance.mainPlayer;
    }
Пример #7
0
    void Start()
    {
        // 백그라운드의 반지름
        radius = rect_Background.rect.width * 0.5f;

        shootingCoolTime = 1.75f;

        mainCameraIsometricScript = GameObject.Find("Main Camera").GetComponent <IsometricCamera>();
    }
    /*on screen debug
     * private Text directionText;
     * private Text speedText;
     * private Text moveText;
     * private Text groundedText;
     * private Text distanceText;
     * private Text crouchText;*/

    void Awake()
    {
        kayaRB           = GetComponent <Rigidbody> ();                   //init player rigid body component\
        kayaCollider     = GetComponent <CapsuleCollider> ();             //init player collider
        anim             = GetComponent <Animator> ();                    //init player animation component
        cam              = Camera.main.transform;                         //init main camera transform
        isoCam           = Camera.main.GetComponent <IsometricCamera> (); //init isoCam component of main camera
        startingMaterial = kayaCollider.material;                         //init starting capsule collider material
        wilhelmDeath     = GetComponent <AudioSource>();
    }
Пример #9
0
        public void ConfigureCamera()
        {
            camera = null;
            camera = new IsometricCamera(Vector3.Zero, 10000f, 1f, float.MaxValue, graphics.GraphicsDevice);
            // Zoom camera to fit world
            // Get largest side
            float largestSide = (float)Math.Sqrt(Math.Pow(world.RealSize.Z, 2) + Math.Pow(world.RealSize.X, 2));
            // Get largest screen side
            int lsg = Math.Min(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height);

            camera.Zoom = largestSide / lsg;
        }
Пример #10
0
 protected override void Awake()
 {
     base.Awake();
     if (Camera == null)
     {
         Camera[] allCameras = UnityEngine.Camera.allCameras;
         foreach (var c in allCameras)
         {
             Camera = c.GetComponent <IsometricCamera>();
             if (Camera != null)
             {
                 break;
             }
         }
     }
 }
    private void Start()
    {
        // Get the transform of the main camera to allow for camera-relative controls
        if (Camera.main != null)
        {
            cam = Camera.main.transform;
        }
        else
        {
            Debug.LogWarning(
                "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
        }

        // Initialize variables
        character = GetComponent<RobotCharacter>();
		ragdoll = GetComponent<RobotRagdoll>();
		isoCam = Camera.main.GetComponent<IsometricCamera>();
		crouch = false;
		guard = false;
		leftTriggerReleased = true;
		rightTriggerReleased = true;
    }
    void Start()
    {
        kayaRB       = GetComponent <Rigidbody> ();                     //init player rigid body component\
        kayaCollider = GetComponent <CapsuleCollider>();                //init player collider
        anim         = GetComponent <Animator>();                       //init player animation component
        cam          = Camera.main.transform;                           //init main camera transform
        isoCam       = Camera.main.GetComponent <IsometricCamera>();    //init isoCam component of main camera

        //debug UI components
        speedText     = GameObject.Find("/Canvas/Speed").GetComponent <Text>();
        directionText = GameObject.Find("/Canvas/Direction").GetComponent <Text> ();
        moveText      = GameObject.Find("/Canvas/MoveVector").GetComponent <Text> ();
        groundedText  = GameObject.Find("/Canvas/Grounded").GetComponent <Text> ();


        //define avatarBones with rigid bodies in player game object

        avatarBones = gameObject.GetComponentsInChildren <Rigidbody>();

        //set avatarBones to kinematic

        foreach (Rigidbody bone in avatarBones)
        {
            bone.isKinematic = true;
        }

        //reset player parent rigid body component to non kinematic

        kayaRB.isKinematic = false;
        kayaRB.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;

        //debug for iso controller
        //Debug.Log("camera forward vector: " + cam.forward);
        //Debug.Log ("player forward vector: " + transform.forward);
        //turnAssistSpeed = 0.0f;

        mask = ~mask;
    }
Пример #13
0
 public void StartScene()
 {
     GameManager.State = GameState.Menu;
     IsometricCamera.ResetLevelZoomIn();
     Instance.StartCoroutine(Instance.LoadAsync(LevelSetManager.CurrentLevel.scenename));
 }
Пример #14
0
 public void CloseSceneLineUp()
 {
     IsometricCamera.StartLevelZoomIn();
     CloseMenuScreen();
 }
Пример #15
0
 protected override void OnEnable()
 {
     base.OnEnable();
     t = (IsometricCamera)target;
     SceneView.onSceneGUIDelegate += OnSceneGUIDelegate;
 }
Пример #16
0
    /// <summary>
    /// Called when a player has connected for the first time to spawn them on the given
    /// spawnPoint and creates/associates the player camera
    /// </summary>
    /// <param name="playerId"></param>
    public void RegisterPlayer(string playerId, string playerName, int spawnIndex, bool isLocalPlayer = false)
    {
        // Index not recognized
        if (spawnIndex < 0 || spawnIndex >= this.spawnPoints.Length)
        {
            Debug.Log("Spawn Index: " + spawnIndex + " not recognized. Using a random one instead");
            spawnIndex = Random.Range(0, this.spawnPoints.Length);
        }

        // Position and Color for the tank
        SpawnPointInfoStruct spawnInfo = this.spawnPoints[spawnIndex];

        // Player already registered?
        // Then make sure that we still have the correct position and player name associtaed with them
        // Also, make sure the colors are correct
        if (this.activeUsers.ContainsKey(playerId))
        {
            Player activeplayer = this.activeUsers[playerId];
            activeplayer.GamerTag             = playerName;
            activeplayer.transform.position   = spawnInfo.transform.position;
            activeplayer.MeshRendererMaterial = spawnInfo.material;
            return;
        }

        // Set the spawn point
        Vector3 spawnPoint = spawnInfo.transform.position;

        // Container for all player objects
        GameObject mainContainerGO = GameObject.Find("_Players");

        // Not created yet
        if (mainContainerGO == null)
        {
            mainContainerGO = new GameObject("_Players");
        }

        // Container for this new player
        GameObject playerContainerGO = new GameObject(playerId);

        playerContainerGO.transform.SetParent(mainContainerGO.transform);

        GameObject camPrefab = this.socketCameraPrefab;

        if (isLocalPlayer)
        {
            camPrefab = this.localCameraPrefab;
        }

        GameObject playerGO = Instantiate(this.playerPrefab, spawnPoint, Quaternion.identity, playerContainerGO.transform);
        GameObject cameraGO = Instantiate(camPrefab, playerContainerGO.transform);

        playerGO.name = "Tank";
        cameraGO.name = "Camera";

        Player          player    = playerGO.GetComponent <Player>();
        IsometricCamera isoCamera = cameraGO.GetComponent <IsometricCamera>();

        player.GamerTag  = playerName;
        player.PlayerId  = playerId;
        player.IsoCamera = cameraGO.GetComponentInChildren <Camera>();
        isoCamera.Target = playerGO.transform;

        // Update the tank's color and gamer tag color
        player.MeshRendererMaterial = spawnInfo.material;
        player.GamerTagColor        = spawnInfo.gamerTagColor;

        // Make the player face towards the center of the map on spawn
        Vector3    lookAt     = Vector3.zero - playerGO.transform.position;
        Quaternion currentRot = playerGO.transform.rotation;
        Quaternion targetRot  = Quaternion.LookRotation(lookAt);

        playerGO.transform.rotation = targetRot;

        // Finally, local players require the "local player" component
        if (isLocalPlayer)
        {
            playerGO.AddComponent <LocalPlayerController>();
            localPlayer = player;

            // Set the waypoint marker to use the gamer tag color
            GameObject.FindGameObjectWithTag("Waypoint").GetComponent <WaypointMarker>().WaypointColor = spawnInfo.gamerTagColor;
        }

        // Register player
        this.activeUsers.Add(playerId, player);
    }