예제 #1
0
파일: Enemy.cs 프로젝트: jthigh/paxdevdemo
 public void Reset()
 {
     this.position = initialPosition;
     sprite.PlayAnimation(idleAnimation);
     waitTime  = 0.0f;
     direction = FaceDirection.Left;
 }
예제 #2
0
        //plays an animation that is on this animator and creates a coroutine that can be yielded to
        public IEnumerator PlayClipYield(string clipName, float angle)
        {
            if (!animations.ContainsKey(clipName))
            {
                yield break;
            }

            //if same direction is already playing break out of coroutine
            if (currentAni != null && currentAni.name == clipName && currentAni.isPlaying)
            {
                if (currentAni.getCurrentDirGroup.direction == FaceDirection.GetDirectionFromAngle(angle, currentAni.use8wayDir))
                {
                    yield break;
                }
            }

            //stop whatever clip was already playing
            if (currentAni != null && currentAni.isPlaying && currentAni != animations[clipName])
            {
                currentAni.Stop();
            }

            currentAni = animations[clipName];

            yield return(StartCoroutine(currentAni.PlayAnimationYield(angle)));
        }
예제 #3
0
        public MovementActionResult SetPositionOnBoard(int placementX, int placementY, FaceDirection facingDirection)
        {
            if (IsLocationWithinBoard(placementX, placementY))
            {
                _locationX       = placementX;
                _locationY       = placementY;
                _facingDirection = facingDirection;
                return(new MovementActionResult(MovementStatus.RobotPlacementSuccessful));
            }
            else if (placementX > _tableSize - 1)
            {
                return(new MovementActionResult(MovementStatus.MoveXOutOfBoardMaxSize));
            }
            else if (placementX < 0)
            {
                return(new MovementActionResult(MovementStatus.MoveXOutOfBoardMinSize));
            }
            else if (placementY > _tableSize - 1)
            {
                return(new MovementActionResult(MovementStatus.MoveYOutOfBoardMaxSize));
            }
            else if (placementY < 0)
            {
                return(new MovementActionResult(MovementStatus.MoveYOutOfBoardMinSize));
            }

            return(new MovementActionResult(MovementStatus.MoveCannotBeDetermined));
        }
예제 #4
0
        public static BlockFace GenerateFace(FaceDirection direction)
        {
            switch (direction)
            {
            case FaceDirection.Front:
                return(new BlockFace(F1, F2));

            case FaceDirection.Back:
                return(new BlockFace(BK1, BK2));

            case FaceDirection.Top:
                return(new BlockFace(T1, T2));

            case FaceDirection.Bottom:
                return(new BlockFace(B1, B2));

            case FaceDirection.Left:
                return(new BlockFace(L1, L2));

            case FaceDirection.Right:
                return(new BlockFace(R1, R2));

            default:
                return(default);
            }
        }
예제 #5
0
 public FaceEmission(Color32 color, byte distance, FaceDirection faceDirection, int indexVerticesBegin)
 {
     this.color = color;
     this.distance = distance;
     this.faceDirection = faceDirection;
     this.indexVerticesBegin = indexVerticesBegin;
 }
예제 #6
0
        //TODO : rewrite rotation
        public static FaceDirection Rotate(FaceDirection face, Vector3 rotation)
        {
            var vector = FaceVectors[face];
            var quat   = Quaternion.Euler(rotation);

            return(PrincipleFace(quat * vector));
        }
예제 #7
0
        /******
         * ANGLES
         *****/
        //gets the proper direction based on the given angle and returns the direction group
        DirectionGroup frameGroupFromAngle(float angle)
        {
            FaceDirection.Direction direction;

            if (angle < 0)
            {
                direction = FaceDirection.Direction.None;
            }
            else
            {
                direction = FaceDirection.GetDirectionFromAngle(angle, use8wayDir);
            }

            DirectionGroup groupToPlay = null;

            foreach (DirectionGroup frameGroup in frameGroups)
            {
                if (frameGroup.direction == direction)
                {
                    groupToPlay = frameGroup;
                    break;
                }
            }

            return(groupToPlay);
        }
예제 #8
0
    private int GetAdjacentVoxel(VoxelMap map, IntVector3 key, FaceDirection dir, out IntVector3 adjacentVoxel)
    {
        switch (dir)
        {
        case FaceDirection.TOP: adjacentVoxel = key.Translate(0, 1, 0); break;

        case FaceDirection.BOTTOM: adjacentVoxel = key.Translate(0, -1, 0); break;

        case FaceDirection.RIGHT: adjacentVoxel = key.Translate(1, 0, 0); break;

        case FaceDirection.LEFT: adjacentVoxel = key.Translate(-1, 0, 0); break;

        case FaceDirection.FRONT: adjacentVoxel = key.Translate(0, 0, 1); break;

        case FaceDirection.BACK: adjacentVoxel = key.Translate(0, 0, -1); break;

        default:
            adjacentVoxel = IntVector3.ZERO;
            return(0);
        }

        if (adjacentVoxel.x < 0 ||
            adjacentVoxel.y < 0 ||
            adjacentVoxel.z < 0 ||
            adjacentVoxel.x >= map.Columns ||
            adjacentVoxel.y >= map.Rows ||
            adjacentVoxel.z >= map.Pages)
        {
            return(0);
        }
        else
        {
            return(VoxelMap[adjacentVoxel]);
        }
    }
예제 #9
0
파일: Enemy.cs 프로젝트: sq/SampleFNA
        /// <summary>
        /// Paces back and forth along a platform, waiting at either end.
        /// </summary>
        public void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Calculate tile position based on the side we are walking towards.
            float posX  = Position.X + localBounds.Width / 2 * (int)direction;
            int   tileX = (int)Math.Floor(posX / Tile.Width) - (int)direction;
            int   tileY = (int)Math.Floor(Position.Y / Tile.Height);

            if (waitTime > 0)
            {
                // Wait for some amount of time.
                waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
                if (waitTime <= 0.0f)
                {
                    // Then turn around.
                    direction = (FaceDirection)(-(int)direction);
                }
            }
            else
            {
                // If we are about to run into a wall or off a cliff, start waiting.
                if (Level.GetCollision(tileX + (int)direction, tileY - 1) == TileCollision.Impassable ||
                    Level.GetCollision(tileX + (int)direction, tileY) == TileCollision.Passable)
                {
                    waitTime = MaxWaitTime;
                }
                else
                {
                    // Move in the current direction.
                    Vector2 velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
                    position = position + velocity;
                }
            }
        }
예제 #10
0
        public void tick()
        {
            getSprites().setSprites(-1, -1);
            int sprite = -1;
            if (inCombat())
            {
                Combat.combatLoop(this);
            }
            if (getFollow().getFollowing() != null && !isFrozen())
            {
                getFollow().followEntity();
                return;
            }
            if (minimumCoords == null || maximumCoords == null) return; //cannot process walking
            if (misc.randomDouble(1) > 0.8 && walkType == WalkType.RANGE && !inCombat() && !isDead() && !isFrozen())
            {
                int tgtX = getLocation().getX() + misc.random(-1, 2); //random number from -1,0,1
                int tgtY = getLocation().getY() + misc.random(-1, 2); //random number from -1,0,1
                sprite = WalkingQueue.direction(getLocation().getX(), getLocation().getY(), tgtX, tgtY);
			    if(tgtX > maximumCoords.getX() || tgtX < minimumCoords.getX() || tgtY > maximumCoords.getY() || tgtY < minimumCoords.getY()) 
                {
                    sprite = -1;
                }
                if (sprite != -1)
                {
                    sprite >>= 1;
                    faceDirection = (FaceDirection)sprite;
                    getSprites().setSprites(sprite, -1);
                    setLocation(new Location(tgtX, tgtY, getLocation().getZ()));
                }
                return;
            }
        }
예제 #11
0
 void MoveByInput()
 {
     if (Input.GetKey(KeyCode.W))
     {
         curState = CharacterState.Walk;
         transform.Translate(Vector2.up * Time.deltaTime * MoveSpeed);
     }
     else if (Input.GetKey(KeyCode.A))
     {
         curState = CharacterState.Walk;
         transform.Translate(Vector2.left * Time.deltaTime * MoveSpeed);
         curDirection = FaceDirection.Left;
     }
     else if (Input.GetKey(KeyCode.S))
     {
         curState = CharacterState.Walk;
         transform.Translate(Vector2.down * Time.deltaTime * MoveSpeed);
     }
     else if (Input.GetKey(KeyCode.D))
     {
         curState = CharacterState.Walk;
         transform.Translate(Vector2.right * Time.deltaTime * MoveSpeed);
         curDirection = FaceDirection.Right;
     }
     else if (Input.GetKey(KeyCode.Space))
     {
         curState = CharacterState.Attack;
     }
     else
     {
         curState = CharacterState.Idle;
     }
 }
예제 #12
0
    /// <summary>
    /// Generates the mesh data for a face of a cube
    /// </summary>
    /// <param name="dir">direction of face</param>
    /// <param name="pointPos">point position of the cube</param>
    public void GenerateCubeFace(FaceDirection dir, Vector3 pointPos, int cubetype)
    {
        int vertIndex = vertices.Count;

        switch (dir)
        {
        case FaceDirection.xp:
            vertices.AddRange(new Vector3[] { pointPos + new Vector3(0.5f, -0.5f, -0.5f),
                                              pointPos + new Vector3(0.5f, 0.5f, -0.5f),
                                              pointPos + new Vector3(0.5f, -0.5f, 0.5f),
                                              pointPos + new Vector3(0.5f, 0.5f, 0.5f) });
            break;

        case FaceDirection.xm:
            vertices.AddRange(new Vector3[] { pointPos + new Vector3(-0.5f, -0.5f, -0.5f),
                                              pointPos + new Vector3(-0.5f, -0.5f, 0.5f),
                                              pointPos + new Vector3(-0.5f, 0.5f, -0.5f),
                                              pointPos + new Vector3(-0.5f, 0.5f, 0.5f) });
            break;

        case FaceDirection.yp:
            vertices.AddRange(new Vector3[] { pointPos + new Vector3(-0.5f, 0.5f, -0.5f),
                                              pointPos + new Vector3(-0.5f, 0.5f, 0.5f),
                                              pointPos + new Vector3(0.5f, 0.5f, -0.5f),
                                              pointPos + new Vector3(0.5f, 0.5f, 0.5f) });
            break;

        case FaceDirection.ym:
            vertices.AddRange(new Vector3[] { pointPos + new Vector3(-0.5f, -0.5f, -0.5f),
                                              pointPos + new Vector3(0.5f, -0.5f, -0.5f),
                                              pointPos + new Vector3(-0.5f, -0.5f, 0.5f),
                                              pointPos + new Vector3(0.5f, -0.5f, 0.5f) });
            break;

        case FaceDirection.zp:
            vertices.AddRange(new Vector3[] { pointPos + new Vector3(-0.5f, -0.5f, 0.5f),
                                              pointPos + new Vector3(0.5f, -0.5f, 0.5f),
                                              pointPos + new Vector3(-0.5f, 0.5f, 0.5f),
                                              pointPos + new Vector3(0.5f, 0.5f, 0.5f) });
            break;

        case FaceDirection.zm:
            vertices.AddRange(new Vector3[] { pointPos + new Vector3(-0.5f, -0.5f, -0.5f),
                                              pointPos + new Vector3(-0.5f, 0.5f, -0.5f),
                                              pointPos + new Vector3(0.5f, -0.5f, -0.5f),
                                              pointPos + new Vector3(0.5f, 0.5f, -0.5f) });
            break;
        }
        triangles.AddRange(new int[] { vertIndex, vertIndex + 1, vertIndex + 2 });
        triangles.AddRange(new int[] { vertIndex + 2, vertIndex + 1, vertIndex + 3 });

        if (cubetype == 1)
        {
            colors.AddRange(Enumerable.Repeat(Color.green, 4).ToArray());
        }
        else if (cubetype == 2)
        {
            colors.AddRange(Enumerable.Repeat(Color.red, 4).ToArray());
        }
    }
        private void UpdateSprite(EnumData.EnemyState enemyState, FaceDirection faceDirection)
        {
            switch (enemyType)
            {
            case EnumData.MonsterBreed.Cyclops:
                UpdateEnemyAnimation(enemyState, faceDirection, cyclopsEnemyDisplayData);
                break;

            case EnumData.MonsterBreed.Centaur:
                UpdateEnemyAnimation(enemyState, faceDirection, centaurEnemyDisplayData);
                break;

            case EnumData.MonsterBreed.Snakes:
                UpdateEnemyAnimation(enemyState, faceDirection, snakeEnemyDisplayData);
                break;

            case EnumData.MonsterBreed.Minotaur:
                UpdateEnemyAnimation(enemyState, faceDirection, minnataurEnemyDisplayData);
                break;

            case EnumData.MonsterBreed.ZeusHead:
                UpdateEnemyAnimation(enemyState, faceDirection, zeusHeadEnemyDisplayData);
                break;

            case EnumData.MonsterBreed.MirrorKnight:
                UpdateEnemyAnimation(enemyState, faceDirection, mirrorKnightEnemyDisplayData);
                break;
            }
        }
예제 #14
0
 public void Flip(FaceDirection newDirection)
 {    /*
       *     //flip scale
       *     Vector3 theScale = mySprite.localScale;
       *     theScale.x *= -1;
       *     //mySprite.localScale= theScale;
       *
       *     //flip location
       *     Vector3 newLocalPosition = mySprite.localPosition;
       *     newLocalPosition.x *= -1;
       *     mySprite.localPosition = newLocalPosition;
       */
     if (newDirection == FaceDirection.RIGHT)
     {
         mySprite.localPosition = rightPosition;
         mySprite.localScale    = rightScale;
     }
     else if (newDirection == FaceDirection.LEFT)
     {
         mySprite.localPosition = leftPosition;
         mySprite.localScale    = leftScale;
     }
     else if (newDirection == FaceDirection.UP)
     {
         mySprite.localPosition = upPosition;
         mySprite.localScale    = upScale;
     }
     else
     {
         mySprite.localPosition = downPosition;
         mySprite.localScale    = downScale;
     }
 }
        public static Vector2 GetVector2(this FaceDirection faceDirection)
        {
            var direction = Vector2.Zero;

            if (faceDirection.HasFlag(FaceDirection.Up))
            {
                direction += new Vector2(0, -1);
            }
            if (faceDirection.HasFlag(FaceDirection.Down))
            {
                direction += new Vector2(0, 1);
            }
            if (faceDirection.HasFlag(FaceDirection.Left))
            {
                direction += new Vector2(-1, 0);
            }
            if (faceDirection.HasFlag(FaceDirection.Right))
            {
                direction += new Vector2(1, 0);
            }
            if (direction != Vector2.Zero)
            {
                direction.Normalize();
            }
            return(direction);
        }
        void UpdateEnemyAnimation(EnumData.EnemyState enemyState, FaceDirection faceDirection, EnemyDisplayData enemyDisplayData)
        {
            switch (enemyState)
            {
            case EnumData.EnemyState.Idle:
                break;

            case EnumData.EnemyState.Walking:
                UpdateDirectionSprite(enemyDisplayData.walkSprite, faceDirection);
                break;

            case EnumData.EnemyState.Petrified:
                currentAnimationSpriteGroup = enemyDisplayData.petrificationSprite;
                break;

            case EnumData.EnemyState.Pushed:
                break;

            case EnumData.EnemyState.PhysicsControlled:
                break;

            case EnumData.EnemyState.PrimaryMoveUse:
                UpdateDirectionSprite(enemyDisplayData.primaryMove, faceDirection);
                break;

            case EnumData.EnemyState.SecondaryMoveUse:
                UpdateDirectionSprite(enemyDisplayData.secondaryMove, faceDirection);
                break;
            }
        }
예제 #17
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Wall") || (gameObject.CompareTag("Player1") && other.gameObject.CompareTag("Player2")) ||
            (gameObject.CompareTag("Player2") && other.gameObject.CompareTag("Player1")))
        {
            switch (dir)
            {
            case FaceDirection.Down:
                dir = FaceDirection.Up;
                anim.SetTrigger("UpWalk");
                break;

            case FaceDirection.Up:
                dir = FaceDirection.Down;
                anim.SetTrigger("DownWalk");
                break;

            case FaceDirection.Left:
                dir = FaceDirection.Right;
                anim.SetTrigger("RightWalk");
                break;

            case FaceDirection.Right:
                dir = FaceDirection.Left;
                anim.SetTrigger("LeftWalk");
                break;
            }
        }
    }
예제 #18
0
    void EnemyMove()
    {
        transform.position = nextPosition;
        dir = nextDir;
        switch (dir)
        {
        case FaceDirection.Up:
            anim.SetTrigger("UpWalk");
            //transform.position = new Vector2(nextPosition.x, nextPosition.y + 0.1f);
            break;

        case FaceDirection.Down:
            anim.SetTrigger("DownWalk");
            //transform.position = new Vector2(nextPosition.x, nextPosition.y - 0.1f);
            break;

        case FaceDirection.Left:
            anim.SetTrigger("LeftWalk");
            //transform.position = new Vector2(nextPosition.x - 0.1f, nextPosition.y);
            break;

        case FaceDirection.Right:
            anim.SetTrigger("RightWalk");
            //transform.position = new Vector2(nextPosition.x + 0.1f, nextPosition.y);
            break;
        }
    }
예제 #19
0
        public void NotifyFaceDirection(IAttackableUnit u, Vector2 direction, bool isInstant = true, float turnTime = 0.0833f)
        {
            var height = _navGrid.GetHeightAtLocation(direction);
            var fd     = new FaceDirection(u, direction.X, direction.Y, height, isInstant, turnTime);

            _packetHandlerManager.BroadcastPacketVision(u, fd, Channel.CHL_S2C);
        }
예제 #20
0
파일: VoxelFace.cs 프로젝트: xenrik/blocks
    /**
     * Constructor accepting the origin, direction and halfScale. This
     * initialises the coordinates
     */
    public VoxelFace(Vector3 origin, FaceDirection dir, float halfScale)
    {
        this.Origin    = origin;
        this.Direction = dir;

        InitialiseCoordinates(halfScale);
    }
예제 #21
0
    private void Update()
    {
        if (player == null)
        {
            player = GameObject.FindGameObjectWithTag("Player");
        }

        if (!mySpriteRenderer.isVisible)
        {
            return;
        }

        if (dir == FaceDirection.LEFT)
        {
            mySpriteRenderer.flipX = false;
        }
        else if (dir == FaceDirection.RIGHT)
        {
            mySpriteRenderer.flipX = true;
        }

        if (player.transform.position.x < transform.position.x)
        {
            dir = FaceDirection.LEFT;
        }
        else
        {
            dir = FaceDirection.RIGHT;
        }
    }
예제 #22
0
        public override void BeginToUse(Actor actorUsing, OnUsed <Actor> onUseBegin, OnUsed <Actor> onDynamicItemUsed)
        {
            //Casting projectile here
            this.actorUsing = actorUsing;
            onUseOver       = onDynamicItemUsed;

            attack = actorUsing.currentAttack;
            projectileTypeThrown = actorUsing.currentAttack.projectiles;
            actorHadAuthority    = actorUsing.hasAuthority();
            gameObjectInstanceId = actorUsing.gameObject.GetInstanceID();
            ownerId = actorUsing.ownerId;
            //Debug.LogError("PProjectile to throw type "+projectileTypeThrown.ToString());
            GameObject gToSpawn = Resources.Load(projectileTypeThrown.ToString()) as GameObject;

            if (gToSpawn == null)
            {
                Debug.LogError("gToSpawn is null");
                return;
            }
            liveProjectile = GridManager.InstantiateGameObject(gToSpawn).GetComponent <ProjectileUtil>();
            liveProjectile.transform.position = GridManager.instance.cellToworld(actorUsing.positionToSpawnProjectile);
            initPos  = liveProjectile.transform.position;
            finalPos = actorUsing.actorTransform.position + (liveProjectile.projectileTileTravelDistance * GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing));
            tileMovementDirection = actorUsing.Facing;
            liveProjectile.Initialise(this);

            //if (projectileTypeThrown==EnumData.Projectiles.FlamePillar)
            //{
            //    liveProjectile.transform.position = actorUsing.actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing);
            //    finalPos = actorUsing.actorTransform.position + GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing) + (liveProjectile.projectileTileTravelDistance * GridManager.instance.GetFacingDirectionOffsetVector3(actorUsing.Facing));
            //}
        }
예제 #23
0
 public MovementActionResult(int?x, int?y, FaceDirection facedirection, MovementStatus movementStatus)
 {
     LocationX = x;
     LocationY = y;
     Direction = facedirection;
     Status    = movementStatus;
 }
예제 #24
0
    public void SendPlayerCurrentInfo(Vector2 pos, FaceDirection dir, int player)
    {
        int count = 0;

        switch (dir)
        {
        case FaceDirection.Up:
            count = 0;
            break;

        case FaceDirection.Down:
            count = 1;
            break;

        case FaceDirection.Left:
            count = 2;
            break;

        case FaceDirection.Right:
            count = 3;
            break;
        }
        byte[] byteToSend = new byte[msgLen];
        string posStr     = ",6" + "," + player.ToString() + "," + pos.ToString() + "," + count.ToString();

        byteToSend = Encoding.ASCII.GetBytes(posStr);
        serverSocket.Send(byteToSend);
    }
예제 #25
0
    /*
     * void CameraMove(string str)
     * {
     *      if(gameObject.name == "Player1" && PlayerStatusControl_Level2._instance.isPlayer1)
     *      {
     *              camAnimator.SetTrigger(str);
     *      }else if(gameObject.name == "Player2" && !PlayerStatusControl_Level2._instance.isPlayer1)
     *      {
     *              camAnimator.SetTrigger(str);
     *      }
     * }
     */

    private void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag("Player1") || other.gameObject.CompareTag("Player2"))
        {
            return;
        }
        switch (dir)
        {
        case FaceDirection.Down:
            dir = FaceDirection.Up;
            anim.SetTrigger("UpWalk");
            break;

        case FaceDirection.Up:
            dir = FaceDirection.Down;
            anim.SetTrigger("DownWalk");
            break;

        case FaceDirection.Left:
            dir = FaceDirection.Right;
            anim.SetTrigger("RightWalk");
            break;

        case FaceDirection.Right:
            dir = FaceDirection.Left;
            anim.SetTrigger("LeftWalk");
            break;
        }
    }
예제 #26
0
 public void StartPush(Actor actorToPush, FaceDirection directionOfPush)
 {
     actorToPush.mapperList.Add(new OneDNonCheckingMapper(directionOfPush));
     actorToPush.Facing   = directionOfPush;
     actorToPush.isPushed = true;
     actorToPush.isHeadCollisionWithOtherActor = false;
 }
예제 #27
0
        public static Vector3d GetVectorPlaneFromEdx(string edx, FaceDirection dir, int location)
        {
            Dictionary <string, string> outputKeys = GetOutputKeys(edx);

            List <double> sequenceX = outputKeys["spacing_x"].Split(',')
                                      .ToList().ConvertAll(v => Convert.ToDouble(v));
            List <double> sequenceY = outputKeys["spacing_y"].Split(',')
                                      .ToList().ConvertAll(v => Convert.ToDouble(v));
            List <double> sequenceZ = outputKeys["spacing_z"].Split(',')
                                      .ToList().ConvertAll(v => Convert.ToDouble(v));

            List <double> accumulateX = Util.Accumulate(sequenceX).ToList();
            List <double> accumulateY = Util.Accumulate(sequenceY).ToList();
            List <double> positionZ   = Util.Accumulate(sequenceZ).ToList().Zip(sequenceZ, (a, b) => a - (b / 2)).ToList();

            if (dir == FaceDirection.X)
            {
                return(new Vector3d(accumulateX[location], 0, 0));
            }
            else if (dir == FaceDirection.Y)
            {
                return(new Vector3d(0, accumulateY[location], 0));
            }
            else
            {
                return(new Vector3d(0, 0, positionZ[location]));
            }
        }
예제 #28
0
    public void SendPlayerAllInfo(int player, Vector2 pos, FaceDirection dir, int fire, Vector2 firePos, float hp, int teleport)
    {
        int dirCount = 0;

        switch (dir)
        {
        case FaceDirection.Up:
            dirCount = 0;
            break;

        case FaceDirection.Down:
            dirCount = 1;
            break;

        case FaceDirection.Left:
            dirCount = 2;
            break;

        case FaceDirection.Right:
            dirCount = 3;
            break;
        }
        byte[] byteToSend = new byte[msgLen];
        string infoStr    = ",11" + "," + player.ToString() + "," + pos.ToString() + "," + dirCount.ToString() + ","
                            + fire.ToString() + "," + firePos.ToString() + "," + hp.ToString() + "," + teleport.ToString();

        byteToSend = Encoding.ASCII.GetBytes(infoStr);
        serverSocket.Send(byteToSend);
    }
예제 #29
0
        public static FaceDirection FlipDirection(FaceDirection face)
        {
            switch (face)
            {
            case FaceDirection.XIncreasing:
                return(FaceDirection.XDecreasing);

            case FaceDirection.YIncreasing:
                return(FaceDirection.YDecreasing);

            case FaceDirection.ZIncreasing:
                return(FaceDirection.ZDecreasing);

            case FaceDirection.XDecreasing:
                return(FaceDirection.XIncreasing);

            case FaceDirection.YDecreasing:
                return(FaceDirection.YIncreasing);

            case FaceDirection.ZDecreasing:
                return(FaceDirection.ZIncreasing);

            case FaceDirection.None:
                return(FaceDirection.None);

            default:
                throw new ArgumentOutOfRangeException(nameof(face), face, null);
            }
        }
예제 #30
0
    public Actor GetTheLastActorInChain(Actor firstActor, FaceDirection directionToParseChain)
    {
        bool foundLastElementInChain = false;

        Actor temp      = firstActor;
        Actor prevActor = null;
        Actor nextActor = null;

        while (!foundLastElementInChain)
        {
            prevActor = temp;
            nextActor = prevActor.GetNextPetrifiedActorInDirection(directionToParseChain);

            if (prevActor.gameObject.GetInstanceID() == nextActor.gameObject.GetInstanceID())
            {
                foundLastElementInChain = true;
            }
            else
            {
                temp = nextActor;
            }
        }

        return(nextActor);
    }
예제 #31
0
        public static Vector3Int Neighbor(int x, int y, int z, FaceDirection direction)
        {
            switch (direction)
            {
            case FaceDirection.XIncreasing:
                return(new Vector3Int(x + 1, y, z));

            case FaceDirection.YIncreasing:
                return(new Vector3Int(x, y + 1, z));

            case FaceDirection.ZIncreasing:
                return(new Vector3Int(x, y, z + 1));

            case FaceDirection.XDecreasing:
                return(new Vector3Int(x - 1, y, z));

            case FaceDirection.YDecreasing:
                return(new Vector3Int(x, y - 1, z));

            case FaceDirection.ZDecreasing:
                return(new Vector3Int(x, y, z - 1));

            default:
                throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
            }
        }
예제 #32
0
    public void SnapBackAfterCollision()
    {
        //Snapping back to previous position because of head on collision
        //Debug.Log("bcurrentMovePointCellPosition " + currentMovePointCellPosition + "  previousMovePointCellPosition " + previousMovePointCellPosition);
        Vector3Int prevPos = previousMovePointCellPosition;

        headOnCollisionCell           = currentMovePointCellPosition;
        previousMovePointCellPosition = currentMovePointCellPosition;
        currentMovePointCellPosition  = prevPos;
        headOnCollisionFaceDirection  = Facing;
        switch (headOnCollisionFaceDirection)
        {
        case FaceDirection.Up:
            Facing = FaceDirection.Down;
            break;

        case FaceDirection.Down:
            Facing = FaceDirection.Up;
            break;

        case FaceDirection.Left:
            Facing = FaceDirection.Right;
            break;

        case FaceDirection.Right:
            Facing = FaceDirection.Left;
            break;
        }
        //Debug.Log("acurrentMovePointCellPosition " + currentMovePointCellPosition + "  previousMovePointCellPosition " + previousMovePointCellPosition);
    }
예제 #33
0
 public ShootingTrap(Level level, Point pos, FaceDirection dir)
 {
     if (dir == FaceDirection.Left)
         effects = SpriteEffects.FlipHorizontally;
     tex = level.Content.LoadTexture2D("Traps/Shooting");
     this.pos = new Vector2(pos.X + (dir == FaceDirection.Left ? 35 : 0), pos.Y + 6);
     this.level = level;
 }
예제 #34
0
	    public Npc(int id) {
		    this.id = id;
            npcDef = NpcData.forId(id);
            skills = new NpcSkills(this);
            skills.setMaxLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints()); //this must be first.
            skills.setCurLevel(NpcSkills.SKILL.HITPOINTS, npcDef.getHitpoints());
		    this.setWalkType(WalkType.RANGE);
		    this.faceDirection = FaceDirection.NORTH;
            this.updateFlags = new AppearanceUpdateFlags(this);
	    }
예제 #35
0
 //    public BlockFace GetFace(FaceDirection faceDirection, int textureIndex, FaceLight[] faceLights, FaceDirection[] shadedEdges, float size)
 public BlockFace GetFace(FaceDirection faceDirection, int textureIndex, FaceLight[] faceLights, FaceDirection[] shadedEdges, float size)
 //public BlockFace GetFace(FaceDirection faceDirection, int textureIndex, float size)
 {
     if (blockFaces != null)
         return blockFaces [(int)faceDirection];
     else
     {
         if (size != 0)
             return new BlockFace(faceDirection, textureIndex, size);
         else
             return new BlockFace(faceDirection, textureIndex, faceLights, shadedEdges);
     }
 }
예제 #36
0
        /// <summary>      
        /// Constructor      
        /// </summary>      
        /// <param name="level">The level this platform belongs to.</param>      
        /// <param name="position">Where the platform is in the level.</param>      
        /// <param name="faceDirection">The direction it is moving.</param>      
        /// <param name="moveSpeed">How fast it is moving.</param>      
        /// <param name="maxWaitTime">How long it will wait before turning around.</param>      
        public GlidingPlatform(Level level, Vector2 position, FaceDirection faceDirection,
            float moveSpeed, float maxWaitTime, TileMovement glidermovement, string name)
        {
            this.level = level;                 //We need to know what level the platform is in.
            Position = position;                //We need to know its position in that level.
            this.direction = faceDirection;     //We need to know what direction it will be moving.
            this.moveSpeed = moveSpeed;         //We need to know how fast it moves.
            this.maxWaitTime = maxWaitTime;     //We need to know how long it waits before changing directions.
            this.glidermovement = glidermovement;
            this.name = name;
            //Equiped with these different fields, we can create a variety of glidingPlatforms with minimal effort.
            //We can create slow platforms, fast platforms, and platforms moving different directions.

            LoadContent();
        }
예제 #37
0
파일: Emissions.cs 프로젝트: nauroman/Cells
        public Color32 GetColorByFaceDirection(FaceDirection faceDirection)
        {
            switch (faceDirection)
            {
                case FaceDirection.top:
                    return top;
                case FaceDirection.back:
                    return side;
                case FaceDirection.left:
                    return side;
                case FaceDirection.right:
                    return side;
                case FaceDirection.front:
                    return side;
                case FaceDirection.bottom:
                    return bottom;
            }

            return new Color32();
        }
예제 #38
0
파일: HIVShot.cs 프로젝트: frank44/pewpew
        public HIVShot(Level level, Vector2 position, double y, double x, FaceDirection fd)
        {
            this.level = level;
            basePosition = position;
            this.position = position;

            if (fd == FaceDirection.Left)
            {
                xvelocity = -velocity;
                y *= -1;
            }
            else
            {
                xvelocity = velocity;
                y *= -1;
            }

            time = 0.0f;
            angle = Math.Atan2(y, x);
            LoadContent();
        }
예제 #39
0
    public void ChangeFacingDirection(FaceDirection direction)
    {
        animState = AnimationState.Turn;
        _unit._facingDirection = direction;

        if (direction == FaceDirection.Up)
        {
            _anim = backSkelAnim;
            _anim.gameObject.transform.localScale = new Vector3(1, 1, 1);
            frontSkelAnim.gameObject.SetActive(false);
            backSkelAnim.gameObject.SetActive(true);
            //print("Up");
        }
        else if (direction == FaceDirection.Right)
        {
            _anim = frontSkelAnim;
            _anim.gameObject.transform.localScale = new Vector3(-1, 1, 1);
            frontSkelAnim.gameObject.SetActive(true);
            backSkelAnim.gameObject.SetActive(false);
           // print("Right");
        }
        else if(direction == FaceDirection.Down)
        {
            _anim = frontSkelAnim;
            _anim.gameObject.transform.localScale = new Vector3(1, 1, 1);
            frontSkelAnim.gameObject.SetActive(true);
            backSkelAnim.gameObject.SetActive(false);
           // print("Down");
        }
        else if (direction == FaceDirection.Left)
        {
            _anim = backSkelAnim;
            _anim.gameObject.transform.localScale = new Vector3(-1, 1, 1);
            frontSkelAnim.gameObject.SetActive(false);
            backSkelAnim.gameObject.SetActive(true);
           // print("Left");
        }
    }
예제 #40
0
    public void CacheFaces(bool[] faces, int textureIndex, FaceLight[][] faceLights, FaceDirection[] shadedEdges)
    //public void CacheFaces(bool[] faces, int textureIndex)
    {
        if (faces.Length != 6)
            throw new ArgumentException("faces.Length should be 6 in this order back, front, top, bottom, left, right", "faces");


        if (faceLights.Length != 6)
            throw new ArgumentException("faceLights.Length should be 6 in this order back, front, top, bottom, left, right", "faceLights");
        
        blockFaces = new BlockFace[6];

        count = 0;

        for (int i = 0; i < 6; i++)
        {
            if (faces [i])
            {
                blockFaces [i] = new BlockFace((FaceDirection)i, textureIndex, faceLights [i], shadedEdges);
                count++;
            } else
                blockFaces [i] = null;            
        }
    }
예제 #41
0
파일: BlockFace.cs 프로젝트: nauroman/Cells
        public void ApplyFaceLight(FaceDirection faceDirection, FaceLight faceLight)
        {
            bool highQuality = false;

            if (highQuality)
            {
                for (int i = 0; i < vertices.Length; i++)
                    ApplyVertexColor(i, faceLight);
            } else
            {
                var vv = new Vector3(-0.5f, -0.5f, -0.5f) + faceLight.position;

                float x = vv.x;
                float y = vv.y;
                float z = vv.z;

                if (x < 0)
                    x = -x;

                if (y < 0)
                    y = -y;

                if (z < 0)
                    z = -z;

                var d = (x + y + z) / 3;

                if (d < 9)
                {
                    float dv = d * 11;

                    var lightColor = faceLight.color32;

                    float r = dv < lightColor.r ? lightColor.r - dv : 0;
                    float g = dv < lightColor.g ? lightColor.g - dv : 0;
                    float b = dv < lightColor.b ? lightColor.b - dv : 0;

                    if (r > 0 || g > 0 || b > 0)
                    {
                        var vertexColor = colors32 [0];

                        if (r > 0)
                            vertexColor.r += Convert.ToByte(r);
                        if (g > 0)
                            vertexColor.g += Convert.ToByte(g);
                        if (b > 0)
                            vertexColor.b += Convert.ToByte(b);

                        colors32 [0] = vertexColor;
                        colors32 [1] = vertexColor;
                        colors32 [2] = vertexColor;
                        colors32 [3] = vertexColor;
                    }
                }

            }
        }
예제 #42
0
파일: BlockFace.cs 프로젝트: nauroman/Cells
        public BlockFace(FaceDirection faceDirection, int textureIndex, float s)
        {
            this.faceDirection = faceDirection;

            triangles = new int[]{ 0, 1, 2, 0, 2, 3 };

            byte c = 32;

            colors32 = new Color32[]
            {
                new Color32(c, c, c, 255),
                new Color32(c, c, c, 255),
                new Color32(c, c, c, 255),
                new Color32(c, c, c, 255)
            };

            switch (faceDirection)
            {
                case FaceDirection.back:

                    vertices = new Vector3[]
                    {
                        new Vector3(1.0f - s, s, 1.0f - s),
                        new Vector3(1.0f - s, 1.0f - s, 1.0f - s),
                        new Vector3(s, 1.0f - s, 1.0f - s),
                        new Vector3(s, s, 1.0f - s)
                    };

                    normals = new Vector3[]
                    {
                        Vector3.forward,
                        Vector3.forward,
                        Vector3.forward,
                        Vector3.forward
                    };

                    uv = CubesUVs.cubesUVs [textureIndex].side;

                    break;

                case FaceDirection.front:

                    vertices = new Vector3[]
                    {
                        new Vector3(s, s, s),
                        new Vector3(s, 1.0f - s, s),
                        new Vector3(1.0f - s, 1.0f - s, s),
                        new Vector3(1.0f - s, s, s)
                    };

                    normals = new Vector3[]
                    {
                        Vector3.back,
                        Vector3.back,
                        Vector3.back,
                        Vector3.back
                    };

                    uv = CubesUVs.cubesUVs [textureIndex].side;

                    break;

                case FaceDirection.top:

                    vertices = new Vector3[]
                    {
                        new Vector3(s, 1.0f - s, s),
                        new Vector3(s, 1.0f - s, 1.0f - s),
                        new Vector3(1.0f - s, 1.0f - s, 1.0f - s),
                        new Vector3(1.0f - s, 1.0f - s, s)
                    };

                    normals = new Vector3[]
                    {
                        Vector3.up,
                        Vector3.up,
                        Vector3.up,
                        Vector3.up
                    };

                    uv = CubesUVs.cubesUVs [textureIndex].top;

                    break;

                case FaceDirection.bottom:

                    vertices = new Vector3[]
                    {
                        new Vector3(1.0f - s, s, s),
                        new Vector3(1.0f - s, s, 1.0f - s),
                        new Vector3(s, s, 1.0f - s),
                        new Vector3(s, s, s)
                    };

                    normals = new Vector3[]
                    {
                        Vector3.down,
                        Vector3.down,
                        Vector3.down,
                        Vector3.down
                    };

                    uv = CubesUVs.cubesUVs [textureIndex].bottom;

                    break;


                case FaceDirection.left:

                    vertices = new Vector3[]
                    {
                        new Vector3(s, s, 1.0f - s),
                        new Vector3(s, 1.0f - s, 1.0f - s),
                        new Vector3(s, 1.0f - s, s),
                        new Vector3(s, s, s)
                    };

                    normals = new Vector3[]
                    {
                        Vector3.left,
                        Vector3.left,
                        Vector3.left,
                        Vector3.left
                    };

                    uv = CubesUVs.cubesUVs [textureIndex].side;

                    break;

                case FaceDirection.right:

                    vertices = new Vector3[]
                    {
                        new Vector3(1.0f - s, s, s),
                        new Vector3(1.0f - s, 1.0f - s, s),
                        new Vector3(1.0f - s, 1.0f - s, 1.0f - s),
                        new Vector3(1.0f - s, s, 1.0f - s)
                    };

                    normals = new Vector3[]
                    {
                        Vector3.right,
                        Vector3.right,
                        Vector3.right,
                        Vector3.right
                    };

                    uv = CubesUVs.cubesUVs [textureIndex].side;

                    break;
            }
        }
예제 #43
0
 public void Update(GameTime gameTime)
 {
     float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;
     // Calculate tile position based on the side we are moving towards.
     float posX = Position.X + localBounds.Width / 2 * (int)direction;
     int tileX = (int)Math.Floor(posX / Tile.Width) - (int)direction;
     int tileY = (int)Math.Floor(Position.Y / Tile.Height);
     if (waitTime > 0)
     {
         // Wait for some amount of time.
         waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
         if (waitTime <= 0.0f)
         {
             // Then turn around.
             direction = (FaceDirection)(-(int)direction);
         }
     }
     else
     {
         //If we're about to run into a wall that isn't a MovableTile move in other direction.
         if (Level.GetCollision(tileX + (int)direction, tileY) == TileCollision.Impassable ||
             Level.GetCollision(tileX + (int)direction, tileY) == TileCollision.Platform)
         {
             velocity = new Vector2(0.0f, 0.0f);
             waitTime = MaxWaitTime;
         }
         else
         {
             // Move in the current direction.
             velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
             position = position + velocity;
         }
     }
     if (level.movableTiles.Count > 0)
     {
         //If we're about to run into a MovableTile move in other direction.
         foreach (var movableTile in level.movableTiles)
         {
             if (BoundingRectangle != movableTile.BoundingRectangle)
             {
                 if (BoundingRectangle.Intersects(movableTile.BoundingRectangle))
                 {
                     direction = (FaceDirection)(-(int)direction);
                     velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
                 }
             }
         }
     }
 }
예제 #44
0
        public override void handleInput(Input.InputState inputState)
        {
            if( currentState == State.Attacking )
                return;

            if (currentState == State.Neutral && (inputState.IsNewButtonPress(Buttons.A) || inputState.IsNewKeyPress(Keys.Space)))
            {
                currentState = State.Attacking;
                attackState = AttackState.Diagonal;
                velocity = Vector2.Zero;
                stateTimer = 0;
                return;
            }

            if (currentState == State.Neutral)
            {
                velocity = inputState.currentGamePadState.ThumbSticks.Left;
                velocity.Y *= -1f;
                acceleration = Vector2.Zero;
            }
            else
            {
                acceleration = inputState.currentGamePadState.ThumbSticks.Left * 0.1f;
                acceleration.Y *= -1f;
                return;
            }

            if (velocity.X < 0f && Math.Abs(velocity.X) > Math.Abs(velocity.Y) )
            {
                currentSourceRect = WalkingLeft;
                faceDir = FaceDirection.Left;
            }
            else if (velocity.X > 0f && Math.Abs(velocity.X) > Math.Abs(velocity.Y))
            {
                currentSourceRect = WalkingRight;
                faceDir = FaceDirection.Right;
            }
            else if (velocity.Y < 0f )
            {
                currentSourceRect = WalkingUp;
                faceDir = FaceDirection.Up;
            }
            else if (velocity.Y > 0f)
            {
                currentSourceRect = WalkingDown;
                faceDir = FaceDirection.Down;
            }

            if (Keyboard.GetState().GetPressedKeys().Length > 0)
            {
                velocity = Vector2.Zero;

                if( inputState.currentKeyboardState.IsKeyDown(Keys.W) )
                {
                    currentSourceRect = WalkingUp;
                    faceDir = FaceDirection.Up;
                    velocity.Y = -1;
                }

                if (inputState.currentKeyboardState.IsKeyDown(Keys.A))
                {
                    currentSourceRect = WalkingLeft;
                    faceDir = FaceDirection.Left;
                    velocity.X = -1;
                }

                if (inputState.currentKeyboardState.IsKeyDown(Keys.S))
                {
                    currentSourceRect = WalkingDown;
                    faceDir = FaceDirection.Down;
                    velocity.Y = 1;
                }

                if (inputState.currentKeyboardState.IsKeyDown(Keys.D))
                {
                    currentSourceRect = WalkingRight;
                    faceDir = FaceDirection.Right;
                    velocity.X = 1;
                }

                if (velocity != Vector2.Zero)
                    velocity.Normalize();
            }

            //velocity.Normalize();
            velocity *= maxSpeed;

            animSpeed = velocity.Length() / 18f;
        }
예제 #45
0
파일: Enemy.cs 프로젝트: egmcdonald/radio
        Vector2 velocity; //current veloctity of the  enemy

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor for the Enemy class, creates a new object of type Enemy.
        /// </summary>
        /// <param name="level">current level object</param>
        /// <param name="position">starting position of the enemy sprite</param>
        /// <param name="spriteSet">string representing the enemy type to create</param>
        /// <param name="enemyTextures">earray containing the enemy animation textures</param>
        /// <param name="walkLeft">should the enemy walk left?</param>
        public Enemy(Level level, Vector2 position, String spriteSet, Texture2D[] enemyTextures, bool walkLeft)
        {
            switch (spriteSet) //switch to the required enemy type and initialise it
            {
                case "Armour": this.enemyType = EnemyType.Armour;
                    armour = new Armour();
                    this.textureStart = armour.textureStart;
                    this.value = armour.value;
                    this.speed = armour.speed;
                    break;

                case "Body": this.enemyType = EnemyType.Body;
                    body = new Body();
                    this.textureStart = body.textureStart;
                    this.value = body.value;
                    this.speed = body.speed;
                    break;

                case "Robe": this.enemyType = EnemyType.Robe;
                    robe = new Robe();
                    this.textureStart = robe.textureStart;
                    this.value = robe.value;
                    this.speed = robe.speed;
                    break;
            }

            this.level = level; //initialise the level object
            this.position = position; //initialise the starting position of the enemy

            if (walkLeft) //if the enemy is to walk left
                this.direction = FaceDirection.Left; //set directional state to left
            else //if the enemy is to walk right
                this.direction = FaceDirection.Right; //set directional state to right

            this.enemyTextures = enemyTextures; //initialise the array of enemy textures

            active = true; //enemy is currently active (i.e. running)
            deactiveLimit = 0; //the enemy has been deactivated for 0 iterations
            defeated = false; //enemy is not yet defeated

            //load the remaining enemy content
            LoadContent();
        }
예제 #46
0
파일: BlockFace.cs 프로젝트: nauroman/Cells
 public void ApplyFaceLights(FaceDirection faceDirection, FaceLight[] faceLights)
 {
     for (int i = 0; i < faceLights.Length; i++)
         ApplyFaceLight(faceDirection, faceLights [i]);
 }
예제 #47
0
 public override void SetFaceDirection(FaceDirection faceDirection)
 {
     if (faceDirection == FaceDirection.Ccw)
         GL.FrontFace(FrontFaceDirection.Ccw);
     else if (faceDirection == FaceDirection.Cw)
         GL.FrontFace(FrontFaceDirection.Cw);
 }
예제 #48
0
파일: Enemy.cs 프로젝트: vdikun/GGJ2013
        /// <summary>
        /// Paces back and forth along a platform, waiting at either end.
        /// </summary>
        public void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Calculate tile position based on the side we are walking towards.
            float posX = Position.X + localBounds.Width / 2 * (int)direction;
            int tileX = (int)Math.Floor(posX / Tile.Width) - (int)direction;
            int tileY = (int)Math.Floor(Position.Y / Tile.Height);

            if (waitTime > 0)
            {
                // Wait for some amount of time.
                waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
                if (waitTime <= 0.0f)
                {
                    // Then turn around.
                    direction = (FaceDirection)(-(int)direction);
                }
            }
            else
            {
                // If we are about to run into a wall or off a cliff, start waiting.
                if (Level.GetCollision(tileX + (int)direction, tileY - 1) == TileCollision.Impassable ||
                    Level.GetCollision(tileX + (int)direction, tileY) == TileCollision.Passable)
                {
                    waitTime = MaxWaitTime;
                }
                else
                {
                    // Move in the current direction.
                    Vector2 velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
                    position = position + velocity;
                }
            }
        }
예제 #49
0
        /// <summary>
        /// Gets Gad Yaakov's sprite for the specified face direction and index.
        /// </summary>
        /// <param name="direction">The face direction.</param>
        /// <param name="index">The index.</param>
        private Bitmap GetYaakovSprite(FaceDirection direction, int index)
        {
            if (this.FaceDirection == FaceDirection.Left)
            {
                switch (index)
                {
                    case 0:
                        return Resources.yaakov_left0;
                    case 1:
                        return Resources.yaakov_left1;
                    case 2:
                        return Resources.yaakov_left2;
                    case 3:
                        return Resources.yaakov_left3;
                    case 4:
                        return Resources.yaakov_left4;
                    case 5:
                        return Resources.yaakov_left5;
                }
            }
            else if (this.FaceDirection == FaceDirection.Right)
            {
                switch (index)
                {
                    case 0:
                        return Resources.yaakov_right0;
                    case 1:
                        return Resources.yaakov_right1;
                    case 2:
                        return Resources.yaakov_right2;
                    case 3:
                        return Resources.yaakov_right3;
                    case 4:
                        return Resources.yaakov_right4;
                    case 5:
                        return Resources.yaakov_right5;
                }
            }

            return null;
        }
예제 #50
0
 TiletypeShape GetRelativeTile(DFCoord2d position, FaceDirection direction)
 {
     DFCoord2d relativePosition = new DFCoord2d(position.x, position.y);
     switch (direction)
     {
         case FaceDirection.North:
             relativePosition.y--;
             break;
         case FaceDirection.South:
             relativePosition.y++;
             break;
         case FaceDirection.East:
             relativePosition.x++;
             break;
         case FaceDirection.West:
             relativePosition.x--;
             break;
     }
     return GetSingleTile(relativePosition);
 }
예제 #51
0
파일: PowerUp.cs 프로젝트: BitSits/Gombli
        public void Droped()
        {
            State = PowerState.Drop; sprite.PlayAnimation(dropAnimation);

            // shif the position near to throwing position
            direction = Level.Player.Direction;
            position = Level.Player.Position - new Vector2(-(int)direction * Level.Player.BoundingRectangle.Width / 2 * 0.8f,
                                                            Level.Player.BoundingRectangle.Height * .61f);
        }
예제 #52
0
    void AddSideFace(DFCoord2d position, FaceDirection direction)
    {
        Layer topLayer = Layer.Top;
        Layer bottomLayer = Layer.Base;
        float currentFloorHeight = -0.5f * tileHeight;
        float adjacentFloorHeight = -0.5f * tileHeight;
        switch (GetSingleTile(position))
        {
            case TiletypeShape.WALL:
                currentFloorHeight = 0.5f * tileHeight;
                topLayer = Layer.Top;
                break;
            case TiletypeShape.RAMP:
            case TiletypeShape.FLOOR:
                currentFloorHeight = floorHeight - (0.5f * tileHeight);
                topLayer = Layer.Floor;
                break;
            default:
                break;
        }
        switch (GetRelativeTile(position, direction))
        {
            case TiletypeShape.WALL:
                adjacentFloorHeight = 0.5f * tileHeight;
                bottomLayer = Layer.Top;
                break;
            case TiletypeShape.FLOOR:
                adjacentFloorHeight = floorHeight - (0.5f * tileHeight);
                bottomLayer = Layer.Floor;
                break;
            default:
                break;
        }
        if (currentFloorHeight <= adjacentFloorHeight)
            return;
        int startindex = finalVertices.Count;
        int uvPos = 0;
        switch (direction)
        {
            case FaceDirection.North:
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, currentFloorHeight, -(position.y - 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, currentFloorHeight, -(position.y - 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, adjacentFloorHeight, -(position.y - 0.5f) * tileWidth), bottomLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, adjacentFloorHeight, -(position.y - 0.5f) * tileWidth), bottomLayer));
                uvPos = position.x;
                break;
            case FaceDirection.South:
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, currentFloorHeight, -(position.y + 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, currentFloorHeight, -(position.y + 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, adjacentFloorHeight, -(position.y + 0.5f) * tileWidth), bottomLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, adjacentFloorHeight, -(position.y + 0.5f) * tileWidth), bottomLayer));
                uvPos = 16 - position.x;
                break;
            case FaceDirection.East:
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, currentFloorHeight, -(position.y + 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, currentFloorHeight, -(position.y - 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, adjacentFloorHeight, -(position.y + 0.5f) * tileWidth), bottomLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x + 0.5f) * tileWidth, adjacentFloorHeight, -(position.y - 0.5f) * tileWidth), bottomLayer));
                uvPos = position.y;
                break;
            case FaceDirection.West:
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, currentFloorHeight, -(position.y - 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, currentFloorHeight, -(position.y + 0.5f) * tileWidth), topLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, adjacentFloorHeight, -(position.y - 0.5f) * tileWidth), bottomLayer));
                finalVertices.Add(AdjustForRamps(new Vector3((position.x - 0.5f) * tileWidth, adjacentFloorHeight, -(position.y + 0.5f) * tileWidth), bottomLayer));
                uvPos = 16 - position.y;
                break;
            default:
                break;
        }
        finalUVs.Add(new Vector2(-(float)(uvPos + 1) / 16.0f, -(float)(0) / 16.0f));
        finalUVs.Add(new Vector2(-(float)(uvPos) / 16.0f, -(float)(0) / 16.0f));
        finalUVs.Add(new Vector2(-(float)(uvPos + 1) / 16.0f, -(float)(0 + 1) / 16.0f));
        finalUVs.Add(new Vector2(-(float)(uvPos) / 16.0f, -(float)(0 + 1) / 16.0f));

        finalVertexColors.Add(GetColor(position));
        finalVertexColors.Add(GetColor(position));
        finalVertexColors.Add(GetColor(position));
        finalVertexColors.Add(GetColor(position));

        finalFaces.Add(startindex);
        finalFaces.Add(startindex + 1);
        finalFaces.Add(startindex + 2);

        finalFaces.Add(startindex + 1);
        finalFaces.Add(startindex + 3);
        finalFaces.Add(startindex + 2);
    }
예제 #53
0
        /// <summary>
        /// Paces back and forth along a platform, waiting at either end.
        /// </summary>
        public override void Update()
        {
            if (Manager.Level.Player.IsAlive)
            {
                float elapsed = (float)Manager.GameTime.ElapsedGameTime.TotalSeconds;

                // Calculate tile position based on the side we are walking towards.
                float posX = Position.X + localBounds.Width / 2 * (int)direction;
                int tileX = (int)Math.Floor(posX / Tile.Width) - (int)direction;
                int tileY = (int)Math.Floor(Position.Y / Tile.Height);

                if (waitTime > 0)
                {
                    // Wait for some amount of time.
                    waitTime = Math.Max(0.0f, waitTime - (float)Manager.GameTime.ElapsedGameTime.TotalSeconds);
                    if (waitTime <= 0.0f)
                    {
                        // Then turn around.
                        direction = (FaceDirection)(-(int)direction);
                    }
                }
                else
                {
                    // If we are about to run into a wall or off a cliff, start waiting.
                    if (Manager.Level.GetCollision(tileX + (int)direction, tileY - 1) == TileCollision.Impassable ||
                        Manager.Level.GetCollision(tileX + (int)direction, tileY) == TileCollision.Passable)
                    {
                        waitTime = MaxWaitTime;
                    }
                    else
                    {
                        // Move in the current direction.
                        Vector2 velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
                        Position = Position + velocity;
                    }
                }

                // Touching an enemy instantly kills the player
                if (this.BoundingRectangle.Intersects(Manager.Level.Player.BoundingRectangle))
                {
                    Manager.Level.Player.OnKilled(this);
                }
            }
        }
예제 #54
0
        // Moves back and forth between stopper blocks waiting at either end briefly
        public void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

                if (waitTime > 0)
                {
                    // Wait for some amount of time.
                    waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
                    if (waitTime <= 0.0f)
                    {
                        // Then turn around.
                        direction = (FaceDirection)(-(int)direction);
                        hitStopper = false;
                    }
                }
                else
                {
                    HandleCollisions();

                    if (hitStopper)
                        waitTime = MaxWaitTime;
                    else
                    {
                        // Move in the current direction.
                        if (moveVertical)
                            velocity = new Vector2(0.0f, (int)direction * currMoveSpeed * elapsed);
                        else
                            velocity = new Vector2((int)direction * currMoveSpeed * elapsed, 0.0f);

                        position += velocity;

                        if (playerContact)
                        {
                            // Move player while on the moving platform
                            level.Player.Position += this.velocity;
                        }
                    }
                }

                // If platform is out of bounds remove it from level
                if (this.position.X < 0 || this.position.X > level.Width * Tile.Width || this.position.Y < 0 || this.position.Y > level.Height * Tile.Height)
                    this.Remove();
        }
예제 #55
0
파일: Enemy.cs 프로젝트: BitSits/Gombli
        public void OnHurt(float damage)
        {
            if (damage == -1)
                if (IsPollutant)
                { hurtTime = MaxHurtTime; return; }
                else
                { direction = (FaceDirection)(-(int)direction); return; }

            health -= damage;
            if (health <= 0.0f) sprite.PlayAnimation(dieAnimation);
        }
예제 #56
0
 public HalfVector2[] GetTextureMapping(FaceDirection faceDir)
 {
     return BlockDictionary.Instance.GetTextureMapping(m_type, faceDir);
 }
예제 #57
0
파일: Enemy.cs 프로젝트: BitSits/Gombli
        /// <summary>
        /// Paces back and forth along a platform, waiting at either end.
        /// </summary>
        public void Update(GameTime gameTime)
        {
            if (!IsAlive) return;

            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (hurtTime > 0.0f) hurtTime = Math.Max(0.0f, hurtTime - elapsed);

            // Calculate tile position based on the side we are walking towards.
            float posX = Position.X + (orientation == Orientation.Horizontal ? BoundingCircle.Radius * (int)direction : 0);
            int tileX = (int)Math.Floor(posX / Tile.Width) - (orientation == Orientation.Horizontal ? (int)direction : 0);

            float posY = Position.Y + (orientation == Orientation.Vertical ? BoundingCircle.Radius * (int)direction : 0);
            int tileY = (int)Math.Floor(posY / Tile.Height);

            if (waitTime > 0)
            {
                // Wait for some amount of time.
                waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
            }
            else
            {
                // If we are about to run into a wall or off a cliff, start waiting.
                TileCollision collision = Level.GetCollision(tileX + (orientation == Orientation.Horizontal ? (int)direction : 0), tileY);

                if (collision == TileCollision.Impassable || collision == TileCollision.Reverse
                    || collision == TileCollision.Left || collision == TileCollision.Up
                    || collision == TileCollision.Right || collision == TileCollision.Down
                    || collision == TileCollision.SlopeMinus || collision == TileCollision.SlopePlus)
                {
                    waitTime = MaxWaitTime;
                    Orientation previousType = orientation;

                    if (collision == TileCollision.Up || collision == TileCollision.Down)
                    {
                        orientation = Orientation.Vertical;
                        direction = collision == TileCollision.Up ? FaceDirection.Down : FaceDirection.Up;
                    }
                    if (collision == TileCollision.Left || collision == TileCollision.Right)
                    {
                        orientation = Orientation.Horizontal;
                        direction = collision == TileCollision.Left ? FaceDirection.Right : FaceDirection.Left;
                    }

                    // Then turn around.
                    direction = (FaceDirection)(-(int)direction);

                    if (previousType != orientation) waitTime = 0.0f;
                }
                else
                {
                    // Move in the current direction.
                    Vector2 velocity = new Vector2(orientation == Orientation.Horizontal ? (int)direction : 0.0f,
                        orientation == Orientation.Vertical ? (int)direction : 0.0f);
                    position = position + velocity * MoveSpeed * elapsed;

                    position = new Vector2((float)Math.Round(Position.X), (float)Math.Round(Position.Y));
                }
            }
        }
예제 #58
0
 private int IterateOnFace(FaceDirection direction, ref Vector3Int index)
 {
     int i1;
     switch(direction)
     {
         case FaceDirection.XIncreasing:
         case FaceDirection.XDecreasing:
             i1 = index.Y;
             index.Y = (i1 + 1) % SizeInBlocks;
             if(index.Y < i1)
             {
                 index.Z = (index.Z + 1) % SizeInBlocks;
             }
             break;
         case FaceDirection.YIncreasing:
         case FaceDirection.YDecreasing:
             i1 = index.X;
             index.X = (i1 + 1) % SizeInBlocks;
             if(index.X < i1)
             {
                 index.Z = (index.Z + 1) % SizeInBlocks;
             }
             break;
         case FaceDirection.ZIncreasing:
         case FaceDirection.ZDecreasing:
             i1 = index.Y;
             index.Y = (i1 + 1) % SizeInBlocks;
             if(index.Y < i1)
             {
                 index.X = (index.X + 1) % SizeInBlocks;
             }
             break;
     }
     return m_mappingFunction(index.X, index.Y, index.Z);
 }
예제 #59
0
        /// <summary>
        /// Paces back and forth along a platform, waiting at either end.
        /// </summary>
        public void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Calculate tile position based on the side we are walking towards.
            float posX = Position.X + localBounds.Width / 2 * (int)direction;
            //in tileX = (int)Math.Floor(posX / Tile.Width) - (int)direction;
            //int tileY = (int)Math.Floor(Position.Y / Tile.Height);

            if (waitTime > 0)
            {
                // Wait for some amount of time.
                waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
                if (waitTime <= 0.0f)
                {
                    // Then turn around.
                    direction = (FaceDirection)(-(int)direction);
                }
            }
            else
            {

                    // Move in the current direction.
                    Vector2 velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
                    position = position + velocity;
            }
        }
예제 #60
0
        public void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (!IsAlive)
                return;

            float posX = Position.X + localBounds.Width / 2 * (int)direction;
            int tileX = (int)Math.Floor(posX / Tile.Width) - (int)direction;
            int tileY = (int)Math.Floor(Position.Y / Tile.Height);

            if (waitTime > 0)
            {
                waitTime = Math.Max(0.0f, waitTime - (float)gameTime.ElapsedGameTime.TotalSeconds);
                if (waitTime <= 0.0f)
                    direction = (FaceDirection)(-(int)direction);
            }
            else
            {
                if (Level.GetCollision(tileX + (int)direction, tileY - 1) == TileCollision.Impassable || Level.GetCollision(tileX + (int)direction, tileY) == TileCollision.Passable)
                    waitTime = MaxWaitTime;
                else
                {
                    Vector2 velocity = new Vector2((int)direction * MoveSpeed * elapsed, 0.0f);
                    Position = Position + velocity;
                }
            }
        }