Beispiel #1
0
 public void ConvertDirectionToIntPoint()
 {
     Assert.AreEqual(new IntPoint(0, 1), IntPoint.DirectionToIntPoint(Direction.UP));
     Assert.AreEqual(new IntPoint(1, 0), IntPoint.DirectionToIntPoint(Direction.RIGHT));
     Assert.AreEqual(new IntPoint(0, -1), IntPoint.DirectionToIntPoint(Direction.DOWN));
     Assert.AreEqual(new IntPoint(-1, 0), IntPoint.DirectionToIntPoint(Direction.LEFT));
 }
Beispiel #2
0
        public bool API_CanMove()
        {
            var newPos  = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));
            var newTile = _roomRunner.GetRoom(room.name).GetTile(newPos.localPosition);

            if (newTile == null)
            {
                return(false);
            }
            else if (newTile.GetOccupants().Length > 0)
            {
                foreach (var occupant in newTile.GetOccupants())
                {
                    if (occupant is Pawn)
                    {
                        var p = (occupant as Pawn);
                        if (p.team == this.team)
                        {
                            return(false);
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #3
0
        public void TurnDegrees(int pDegrees)
        {
            int degrees = (int)IntPoint.DirectionToIntPoint(direction).Degrees();

            degrees  -= pDegrees;
            direction = GridMath.DegreesToDirection((int)degrees);
        }
Beispiel #4
0
        public void API_Goto(string doorName)
        {
            if (_user == null)
            {
                D.Log("User for door " + name + " is null");
                //throw new Error ("No user for door " + name);
                return;
            }

            var otherDoor = _tingRunner.GetTingUnsafe(doorName) as Door;

            if (otherDoor != null)
            {
                Room otherRoom        = otherDoor.room;
                var  interactionPoint = otherDoor.interactionPoints [0];
                int  otherX           = interactionPoint.x;
                int  otherY           = interactionPoint.y;

                PushAwayBlockers(otherRoom, otherX, otherY, IntPoint.DirectionToIntPoint(otherDoor.direction));

                WorldCoordinate newPosition = new WorldCoordinate(otherRoom.name, otherX, otherY);

                //D.Log("ExitTroughDoor was called on " + name + " and will now teleport " + _user.name + " to " + newPosition);

                _user.targetPositionInRoom = otherDoor.position;                 // makes the Shell not freak out when it is created in the new scene but target is still in the old one
                _user.position             = newPosition;
                _user.direction            = otherDoor.direction;
                _user.StopAction();
                _user.StartAction("WalkingThroughDoorPhase2", null, 1.35f, 1.35f);
                ResetAttempts();                 // success!

                _dialogueRunner.EventHappened(_user.name + "_open_" + name);
                if (isElevatorEntrance)
                {
                    otherDoor.elevatorFloor = this.elevatorFloor;
                }
            }
            else
            {
                throw new Error("Can't find door with name " + doorName);
            }
        }
Beispiel #5
0
        public void API_Move()
        {
            if (dead)
            {
                return;
            }

            var newPos  = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));
            var newTile = _roomRunner.GetRoom(room.name).GetTile(newPos.localPosition);

            if (newTile == null)
            {
                //D.Log(name + " can't move forward since there is no tile to move to");
            }
            else if (newTile.GetOccupants().Length > 0)
            {
                //D.Log(name + " can't move forward since there are occupants there: ");
                foreach (var occupant in newTile.GetOccupants())
                {
                    //D.Log(occupant.name);
                    if (occupant is Pawn)
                    {
                        var otherPawn = (occupant as Pawn);
                        if (otherPawn.team != this.team && !otherPawn.dead)
                        {
                            otherPawn.GetHit();
                            PlaySound("FishAttack");
                        }
                    }
                }
            }
            else
            {
                position = newPos;
            }

            moveNr++;
        }
Beispiel #6
0
        public void API_Move()
        {
            var newPos = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));

            position = newPos;
        }