Exemplo n.º 1
0
        void ATTile_OnOccupantRemoved(TileMovement occ, ATTile destination)
        {
            if (IsDifficultTerrain)
            {
                stumblingOcc.Remove(occ);
                occ.ActorComponent.CharSheet.OnAboutToAttack     -= CursedWillPerform;
                occ.ActorComponent.CharSheet.OnAboutToBeAttacked -= CursedWillBeAttacked;
//				Debug.LogError ("bla bla");
            }

            //have actors that can see this tile unsee the actor that was removed if they can't see the destination tile and can see enemy.
            foreach (Actor act in actorsThatSeeThisTile)
            {
                Vision eyes = act.GetComponent <Vision> ();
                if (eyes.CanSee(occ.ActorComponent) && act != occ.ActorComponent)
                {
                    if (destination == null)                       //the actor probably died.
                    {
                        Debug.Log("actor: " + eyes.Actor.GetType());
                        eyes.UndiscoverEnemyActor(occ.ActorComponent);
                    }
                    else if (act.EnemiesWith(occ.ActorComponent))
                    {
                        if (!destination.actorsThatSeeThisTile.Contains(act))
                        {
                            eyes.UndiscoverEnemyActor(occ.ActorComponent);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override List <IActionOptionChoice> GetChoicesUnfiltered(Actor actor, Action pickup)
        {
            if (actor.CharSheet.inventory.NoRoomLeft)
            {
                lastReasonForNoChoices = "No room left for any items.";
                return(new List <IActionOptionChoice> ());
            }

            TileMovement tm = actor.GetComponent <TileMovement> ();
            List <IActionOptionChoice> ret = null;

            if (tm.occupying == null)
            {
                ret = new List <IActionOptionChoice> ();
            }
            else
            {
                //Debug.LogError (tm.occupying.onTheGround.Count);
                ret = tm.occupying.OnTheGround.Select((item) => new InventoryItemChoice(item) as IActionOptionChoice).ToList();
            }


            if (ret.Count == 0)
            {
                lastReasonForNoChoices = "No items on the ground.";
            }

            return(ret);
        }
Exemplo n.º 3
0
            public override void Perform()
            {
                CallOnBegan();

                ItemsOnPersonOption opt = ActionOptions [0] as ItemsOnPersonOption;

                InventoryItemChoice choice = opt.chosenChoice as InventoryItemChoice;

                if (actor.CharSheet.inventory.ListOfItems().Contains(choice.item))
                {
                    actor.CharSheet.inventory.RemoveItem(choice.item);
                }
                else if (actor.CharSheet.PaperDoll.slots.ContainsValue(choice.item as Equipment))
                {
                    actor.CharSheet.PaperDoll.Unequip(choice.item as Equipment, actor.CharSheet);
                }



                TileMovement tm = actor.GetComponent <TileMovement> ();

                tm.occupying.AddItemToGround(choice.item);

                CallOnFinished();
            }
Exemplo n.º 4
0
 // 작업 중
 // 이름 변경 후보: TrySwapAdjacentTile
 public void ReqMoveTile(Tile tile, TileMovement move)
 {
     if (gp.TrySwapTile(tile, move) == SwapTileResult.NoTile)
     {
         TileInput.blockInput = false;
     }
 }
    void Awake()
    {
        animationTransform   = GetComponent <AnimationTransform> ();
        tileMovement         = GetComponent <TileMovement> ();
        characterAudioSource = GetComponent <AudioSource>();

        animationTransform.OnAnimationEvent += HandleAnimationEvent;
    }
Exemplo n.º 6
0
 public void RemoveOccupant(TileMovement occ, ATTile desitination)
 {
     currentOccupants.Remove(occ);
     occ.ActorComponent.OnActorKilled -= OnDeathOccupantCleanup;
     if (OnOccupantRemoved != null)
     {
         OnOccupantRemoved(occ, desitination);
     }
 }
Exemplo n.º 7
0
        public void AddOccupant(TileMovement occ, ATTile previous)
        {
            occ.ActorComponent.OnActorKilled += OnDeathOccupantCleanup;
            currentOccupants.Add(occ);

            if (OnOccupantAdded != null)
            {
                OnOccupantAdded(occ, previous);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Loads a gliding tile
        /// </summary>
        private Tile LoadGlidingTile(int x, int y, string name, FaceDirection faceDirection,
                                     float moveSpeed, float waitTime, TileMovement movement)
        {
            Vector2 position = RectangleExtensions.GetBottomCenter(GetBounds(x, y));

            glidingPlatforms.Add(new GlidingPlatform(this, position, faceDirection, moveSpeed, waitTime, movement, name));

            // Just like an enemy, we want the fixed tile behind it to be passable and invisible.
            return(new Tile(null, TileCollision.Passable, movement));
        }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        PlayerSongs ps = FindObjectOfType <PlayerSongs>();

        ps.AddPowerListener(activationPower, Activate);
        currentTargetPosition = position2;
        _rigidBody            = GetComponent <Rigidbody2D>();
        _tileMovement         = GetComponent <TileMovement>();
        _animator             = GetComponent <Animator>();
    }
Exemplo n.º 10
0
    void Start()
    {
        // Starts in the starting position of the current board
        boardScript        = board.GetComponent <BoardState>();
        transform.position = boardScript.startLocation;

        // Uses the start tile to find the first tile that the player can move to
        GameObject   start       = GameObject.FindWithTag("Start");
        TileMovement startScript = start.GetComponent <TileMovement>();

        tile = startScript.nextTile;

        // Resets coins, as the Unity player keeps them from game to game. Need to look into
        coins = 0;
    }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
0
            public override void Perform()
            {
                CallOnBegan();

                ItemPickupOption opt = ActionOptions [0] as ItemPickupOption;

                InventoryItemChoice choice = opt.chosenChoice as InventoryItemChoice;

                actor.CharSheet.inventory.AddItem(choice.item);

                TileMovement tm = actor.GetComponent <TileMovement> ();

                tm.occupying.RemoveItemFromGround(choice.item);

                CallOnFinished();
            }
        public static List <ATTile> OccupyableTilesAdjacentTo(Actor act)
        {
            TileMovement  tm  = act.GetComponent <TileMovement> ();
            List <ATTile> ret = new List <ATTile> ();

            foreach (ATTile n in tm.occupying.Neighbors())
            {
                if (n.Occupyable())
                {
                    ret.Add(n);
                }
            }


            return(ret);
        }
Exemplo n.º 15
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        Vector3 targetPosition = transform.position;

        GameObject   obj          = collider.gameObject;
        TileMovement tileMovement = obj.GetComponent <TileMovement>();

        tileMovement.Lock();
        tileMovement.Stop();

        if (obj.tag == "player")
        {
            switch (direction)
            {
            case Direction.North:
                targetPosition = targetPosition.North();
                break;

            case Direction.South:
                targetPosition = targetPosition.South();
                break;

            case Direction.East:
                targetPosition = targetPosition.East();
                break;

            case Direction.West:
                targetPosition = targetPosition.West();
                break;
            }

            if (isDown)
            {
                targetPosition = targetPosition.FloorDown();
            }
            else
            {
                targetPosition = targetPosition.FloorUp();
            }

            obj.layer = LayerMask.NameToLayer("Floor " + targetPosition.z.ToString());

            obj.transform.position = targetPosition;

            tileMovement.Unlock();
        }
    }
Exemplo n.º 16
0
    // 상태 초기화 메서드
    public void ResetState()
    {
        State            = TILE_STATE.STOP; // 멈춤
        isMatched        = false;           // 매치되지 않음
        IsFalling        = false;           // 떨어지지 않음
        IsNewFallingTile = false;           // 새로 떨어지는 타일 아님
        SwapTarget       = null;            // 스왑 대상 없음

        if (Tm == null)                     // 객체 없으면 생성
        {
            Tm = new TileMovement(transform);
        }
        if (Tff == null) // 객체 없으면 생성
        {
            Tff = new TileFreeFall(transform);
        }
    }
Exemplo n.º 17
0
        public SwapTileResult TrySwapTile(Tile tile, TileMovement move)
        {
            SwapTileResult result;
            Tile           adjTile = GetAdjacentTile(tile, move);

            if (adjTile != null)
            {
                result = SwapTile(tile, adjTile) ? SwapTileResult.Success : SwapTileResult.Failure;
            }
            else
            {
                return(SwapTileResult.NoTile);
            }

            // 리턴 false: 인접 없는 경우, 매치가 발생되지 않는 경우
            return(result);
        }
Exemplo n.º 18
0
            private void AnimatedMovePerform(List <ATTile> thePath)
            {
                TileMovement tm = actor.GetComponent <TileMovement> ();

                List <string> path = DirectionsFrom(cachedPath);

                if (path.Count == 0)
                {
                    FinishedMove();
                }
                else
                {
                    tm.Walk(path);


                    actor.GetComponent <CharacterWalker> ().OnEndedWalking += FinishedMove;
                }
            }
Exemplo n.º 19
0
    public void SetSelectedUnit(TileMovement unit)
    {
        if (selectedUnit != null && selectedUnit != unit)
        {
            selectedUnit.GetComponent <BoxCollider>().enabled = true;
        }

        if (unit != null)
        {
            unit.GetComponent <BoxCollider>().enabled = false;
        }

        if (unit == null && selectedUnit != null)
        {
            selectedUnit.GetComponent <BoxCollider>().enabled = true;
        }

        selectedUnit = unit;

        if (selectedUnit == null)
        {
            startX = 0;
            startZ = 0;

            endX = 0;
            endZ = 0;
        }
        else
        {
            var translatedPosition = grid.GetArrayValueFromTransform(selectedUnit.gameObject.transform);

            startX = (int)translatedPosition.x;
            startZ = (int)translatedPosition.z;

            endX = startX;
            endZ = startZ;

            SetDistance();
            SetPath();
        }
    }
Exemplo n.º 20
0
    void Awake()
    {
        if (avatar == null)
        {
            avatar = transform;
        }

        if (avatar == null)
        {
            throw new UnityException("Tile inhabitant needs an avatar!  If this is a doodad, avatar should be a tile, if it's an entity, it should be a character");
        }

        GetComponent <SpriteRenderer>().sortingLayerName = "TileInhabitant";

        TileMovement tm = GetComponent <TileMovement> ();

        if (tm != null)
        {
            tm.OnWalkedOutOfTile += AvatarMovedInto;
        }
    }
Exemplo n.º 21
0
        public Tile GetAdjacentTile(Tile tile, TileMovement move)
        {
            var  location = tile.GetLocation();
            Tile adjTile  = null;

            if (move == TileMovement.Up && location.row > 0)
            {
                adjTile = tiles[location.row - 1, location.col];
            }
            else if (move == TileMovement.Down && location.row < GetLastIndexRow())
            {
                adjTile = tiles[location.row + 1, location.col];
            }
            else if (move == TileMovement.Left && location.col > 0)
            {
                adjTile = tiles[location.row, location.col - 1];
            }
            else if (move == TileMovement.Right && location.col < GetLastIndexCol())
            {
                adjTile = tiles[location.row, location.col + 1];
            }
            return(adjTile);
        }
Exemplo n.º 22
0
 // Moves the player an amount of tiles equal to their dice roll
 void Movement()
 {
     transform.position = Vector3.Lerp(transform.position, tile.position + new Vector3(0, 0.67f, 0), speed);
     // Grabs the pointer to the next tile every two seconds, so that movement isn't instant
     if (Time.time - timeCheck >= 2)
     {
         tileScript = tile.GetComponent <TileMovement>();
         tile       = tileScript.nextTile;
         timeCheck  = Time.time;
         tilesMoved++;
         int remainingDice = diceRoll - tilesMoved;
         Debug.Log(remainingDice + "(" + diceRoll + ")");
         // Stops movement once the player has moved the given number of tiles
         if (tilesMoved == diceRoll)
         {
             moving = false;
             tileScript.Effect();
             tilesMoved = 0;
             diceRoll   = 0;
             timeCheck  = 0;
         }
     }
 }
Exemplo n.º 23
0
        void ATTile_OnOccupantAdded(TileMovement occ, ATTile previous)
        {
            if (IsDifficultTerrain)
            {
                stumblingOcc.Add(occ);
                occ.ActorComponent.CharSheet.OnAboutToAttack     += CursedWillPerform;
                occ.ActorComponent.CharSheet.OnAboutToBeAttacked += CursedWillBeAttacked;
            }

            //have actors that can see this tile discover the actor that was added if they don't already see it.
            foreach (Actor act in actorsThatSeeThisTile)
            {
                if (occ.ActorComponent == act)
                {
                    continue;
                }
                Vision eyes = act.GetComponent <Vision> ();
                if (act.EnemiesWith(occ.ActorComponent) && !eyes.CanSee(occ.ActorComponent))
                {
                    eyes.DiscoverEnemyActor(occ.ActorComponent);
                }
            }
        }
        void GoInvisibleForUndiscovery(Actor a)
        {
            if (a.IsOnPlayerSide)
            {
                TileMovement tm = GetComponent <TileMovement> ();
                ATTile       tile;
                if (tm != null)
                {
                    tile = tm.occupying;
                }
                else
                {
                    //the visible thing is a weapon or ground effect.
                    tile = MapManager.instance.TileAt(transform.position);
                }

//				Debug.LogError ("undiscovered by an enemy player.  checking if I should go invisible");
//				bool goingInvis = true;
                if (!tile.SeenByAlliesOf(a))
                {
                    GoInvis();
                }
            }
        }
Exemplo n.º 25
0
 // Use this for initialization
 void Start()
 {
     worldMap = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WorldMap> ();
     actor = gameObject.GetComponent<Actor>();
     player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();
     move = gameObject.GetComponent<TileMovement>();
     attack = gameObject.GetComponent<TileAttack>();
     ui = GameObject.FindGameObjectWithTag ("UIMain").GetComponent<UIMain> ();
 }
Exemplo n.º 26
0
 void Start()
 {
     tileMovement = gameObject.GetComponent <TileMovement>();
     SetLastTime();
 }
Exemplo n.º 27
0
    // Use this for initialization
    void Start()
    {
        movementInputTimer = Time.fixedTime;

        options = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameOptions> ();
        worldMap = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WorldMap> ();
        worldSound = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WorldSound> ();

        move = gameObject.GetComponent<TileMovement>();
        attack = gameObject.GetComponent<TileAttack>();

        camera = GameObject.FindGameObjectWithTag ("MainCamera").GetComponent<Camera> ();
        actorManager = GameObject.FindGameObjectWithTag ("GameController").GetComponent<ActorManager> ();

        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();
        ui = GameObject.FindGameObjectWithTag ("UIMain").GetComponent<UIMain> ();
    }
Exemplo n.º 28
0
        /// <summary>
        /// Loads a tile with a random appearance.
        /// </summary>
        /// <param name="baseName">
        /// The content name prefix for this group of tile variations. Tile groups are
        /// name LikeThis0.png and LikeThis1.png and LikeThis2.png.
        /// </param>
        /// <param name="variationCount">
        /// The number of variations in this group.
        /// </param>
        private Tile LoadVarietyTile(string baseName, int variationCount, TileCollision collision, TileMovement movement)
        {
            int index = random.Next(variationCount);

            return(LoadTile(baseName + index, collision, movement));
        }
Exemplo n.º 29
0
 /// <summary>
 /// Creates a new tile. The other tile loading methods typically chain to this
 /// method after performing their special logic.
 /// </summary>
 /// <param name="name">
 /// Path to a tile texture relative to the Content/Tiles directory.
 /// </param>
 /// <param name="collision">
 /// The tile collision type for the new tile.
 /// </param>
 /// <returns>The new tile.</returns>
 private Tile LoadTile(string name, TileCollision collision, TileMovement movement)
 {
     return new Tile(Content.Load<Texture2D>("Tiles/" + name), collision, movement);
 }
Exemplo n.º 30
0
 /// <summary>
 /// Creates a new tile. The other tile loading methods typically chain to this
 /// method after performing their special logic.
 /// </summary>
 /// <param name="name">
 /// Path to a tile texture relative to the Content/Tiles directory.
 /// </param>
 /// <param name="collision">
 /// The tile collision type for the new tile.
 /// </param>
 /// <returns>The new tile.</returns>
 private Tile LoadTile(string name, TileCollision collision, TileMovement movement)
 {
     return(new Tile(Content.Load <Texture2D>("Tiles/" + name), collision, movement));
 }
Exemplo n.º 31
0
 void Awake()
 {
     animator     = GetComponent <Animator> ();
     tileMovement = GetComponent <TileMovement> ();
 }
Exemplo n.º 32
0
        /// <summary>   
        /// Loads a gliding tile  
        /// </summary>   
        private Tile LoadGlidingTile(int x, int y, string name, FaceDirection faceDirection,
            float moveSpeed, float waitTime, TileMovement movement)
        {
            Vector2 position = RectangleExtensions.GetBottomCenter(GetBounds(x, y));
            glidingPlatforms.Add(new GlidingPlatform(this, position, faceDirection, moveSpeed, waitTime, movement, name));

            // Just like an enemy, we want the fixed tile behind it to be passable and invisible.
            return new Tile(null, TileCollision.Passable, movement);
        }
Exemplo n.º 33
0
 public TileMovementSignal(Tile tile, TileMovement move)
 {
     this.tile = tile;
     movement  = move;
 }
Exemplo n.º 34
0
    // Setup
    public void SetupObjectReferences()
    {
        move = gameObject.GetComponent<TileMovement>();
        attack = gameObject.GetComponent<TileAttack>();

        worldMap = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WorldMap> ();
        worldSound = GameObject.FindGameObjectWithTag ("GameController").GetComponent<WorldSound> ();
        ui = GameObject.FindGameObjectWithTag ("UIMain").GetComponent<UIMain> ();
        actorManager = GameObject.FindGameObjectWithTag ("GameController").GetComponent<ActorManager> ();
        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();
        options = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameOptions> ();

        animationPosition = new Vector2(tileX*worldMap.mapTileSize,tileY*worldMap.mapTileSize);
    }
 // Use this for initialization
 void Start()
 {
     _rigidbody    = GetComponent <Rigidbody2D>();
     _tileMovement = GetComponent <TileMovement>();
     slideVector   = Vector2.zero;
 }
Exemplo n.º 36
0
 /// <summary>
 /// Constructs a new tile.
 /// </summary>
 public Tile(Texture2D texture, TileCollision collision, TileMovement movement)
 {
     Texture = texture;
     Collision = collision;
     Movement = movement;
 }
Exemplo n.º 37
0
 /// <summary>
 /// Constructs a new tile.
 /// </summary>
 public Tile(Texture2D texture, TileCollision collision, TileMovement movement)
 {
     Texture   = texture;
     Collision = collision;
     Movement  = movement;
 }
Exemplo n.º 38
0
 /// <summary>
 /// Loads a tile with a random appearance.
 /// </summary>
 /// <param name="baseName">
 /// The content name prefix for this group of tile variations. Tile groups are
 /// name LikeThis0.png and LikeThis1.png and LikeThis2.png.
 /// </param>
 /// <param name="variationCount">
 /// The number of variations in this group.
 /// </param>
 private Tile LoadVarietyTile(string baseName, int variationCount, TileCollision collision, TileMovement movement)
 {
     int index = random.Next(variationCount);
     return LoadTile(baseName + index, collision, movement);
 }