public void CenterOnPlayer( Player player )
        {
            CurrentFace = player.CubeFace;
            UpDir = player.UpDir;

            Screen.Camera.OrbitPosition( CameraDistance * CurrentFace.Normal, Position, CameraDistance );
            Screen.Camera.AnimateUpVector( ComputeUpVector() );
            //Screen.Camera.SkipAnimation();
        }
Example #2
0
 private void ShootProjectile(Player player)
 {
     Vector2 playerPosition = Transform3dTo2d( player.CubePosition );
     Vector3 direction = Vector3.Normalize( player.CubePosition - CubePosition );
     direction.Y = -direction.Y;
     Screen.AddProjectile( CubePosition, direction, Rotation );
 }
Example #3
0
        // we determine if we see the player by using the triangle vision and see if it contains the player
        private bool SeePlayer(Player player)
        {
            Vector2 playerPosition = Transform3dTo2d(player.CubePosition);
            Vector2 pointA = Transform3dTo2d(mVisionVertices[0].Position);
            Vector2 pointB = Transform3dTo2d(mVisionVertices[1].Position);
            Vector2 pointC = Transform3dTo2d(mVisionVertices[2].Position);

            return PointInTriangle(playerPosition, pointA, pointB, pointC);
        }
Example #4
0
        private void OnCloneChanged( Player player )
        {
            AchievementManager.Instance[ Stat.Swap ]++;

            float dist = Vector3.Distance( player.WorldPosition, Player.WorldPosition );

            Camera.AnimateTarget( player.WorldPosition, dist * 4 );
            CloneChanged?.Invoke( player );
        }
Example #5
0
        private Vector3 ComputeCameraPosition( Player p )
        {
            Vector3 playerPos = p.CubePosition;
            Vector3 normal = p.Normal;

            HyperVector3 cubePos = new HyperVector3( playerPos );
            cubePos.Cascade( normal );

            const float sqrt2 = 1.41421356237f;
            Vector3 bias = cubePos.Coalesce(
                v => MathTools.TransformRange( (v / Cube.Scale).Length(), .9f * sqrt2, sqrt2, 0, 1, true ) );

            Vector3 defaultPos = normal * (Cube.CameraDistance - 1) + playerPos;
            //defaultPos = defaultPos.ChangeLength( Cube.CameraDistance );

            HyperVector3 projPos = cubePos.ChangeLength( Cube.CameraDistance );
            projPos.Cascade( defaultPos );

            Vector3 projPosA, projPosB;
            float biasA, biasB;

            #region Project and bias setup
            switch ( normal.LargestComponent() )
            {
            case Vector3Component.X:
                projPosA = projPos.Y;
                projPosB = projPos.Z;
                biasA = bias.Y;
                biasB = bias.Z;
                break;

            case Vector3Component.Y:
                projPosA = projPos.X;
                projPosB = projPos.Z;
                biasA = bias.X;
                biasB = bias.Z;
                break;

            case Vector3Component.Z:
                projPosA = projPos.Y;
                projPosB = projPos.X;
                biasA = bias.Y;
                biasB = bias.X;
                break;

            default:
                throw new EnumException<Vector3Component>( "switch statement" );
            }
            #endregion

            return VectorUtils.Slerp(
                defaultPos.Slerp( projPosA, biasA ),
                defaultPos.Slerp( projPosB, biasB ),
                MathTools.TransformRange( biasB - biasA, -1, 1, 0, 1 ) );
        }
Example #6
0
        public void RemovePlayer( Player player )
        {
            Components.Remove( player );
            mPlayerClones.Remove( player );

            player.Dispose();

            if ( mPlayerClones.Count == 0 )
            {
                ResetLevel();
            }
            else
            {
                mActivePlayerIndex %= mPlayerClones.Count;
                OnCloneChanged( PendingPlayer );
            }
        }
Example #7
0
        public void AddPlayer( Vector3 pos, float rotation )
        {
            Player clone = new Player( this, Cube, pos, rotation );

            mPlayerClones.Add( clone );
            Components.Add( clone );

            clone.Initialize();
        }