示例#1
0
    public void MoveTowards(MovementType move)
    {
        ///////////////////////////////////////
        //Local Variables

        Vector3 newPosition;

        GameObject other;
        TileMove   tileMove       = GetComponent <TileMove>();
        GameObject mainController = GameObject.FindWithTag(TagKeys.MAIN_CONTROLLER_KEY);;

        InputAttack attack = GetComponent <InputAttack>();

        ///////////////////////////////////////

        if (mainController.GetComponent <GameStateController>().CurrentTurnState != TurnState.PLAYER_TURN)
        {
            return;
        }

        newPosition = GetNewPosition(move);
        other       = tileMove.TryMove(newPosition);

        if (other != null)
        {
            attack.AttackCheck(other);
        }
    }
示例#2
0
    IndexMove tileMoveToIndexMove(TileMove tileMove)
    {
        Vector2 startIndex = BoardController.instance.getIndexOfTile(tileMove.tileStart);
        Vector2 endIndex   = BoardController.instance.getIndexOfTile(tileMove.tileEnd);

        IndexMove indexMove = new IndexMove(startIndex, endIndex);

        return(indexMove);
    }
示例#3
0
 protected override void Awake()
 {
     base.Awake();
     rends     = GetComponentsInChildren <Renderer>(true);
     mod       = GetComponent <TileModifier>();
     quest     = GetComponent <TileQuestion>();
     game      = GetComponent <TileMinigame>();
     move      = GetComponent <TileMove>();
     mod.score = quest.score = game.score = move.score = 15;
     mat       = rends[0].material;
 }
示例#4
0
 public void MoveTileVerticallyOverTime(float newLocalY, float duration, TileMove moveComplete = null, TileMove moveCanceled = null)
 {
     DOTween.Kill(InstanceId + 1); // will need a more unique id
     transform.DOLocalMoveY(newLocalY, duration).SetId(InstanceId + 1).OnComplete
         (() =>
     {
         if (moveComplete != null)
         {
             moveComplete();
         }
     });
 }
 public TileMove MoveTile(Tile tile, Vector3 relative)
 {
     var tileMove = tileMoves.FirstOrDefault(tM => tM.Tile == tile);
     if (tileMove == null)
     {
         tileMove = new TileMove
                    {
                        Tile = tile,
                        StartPosition = tile.Position
                    };
         tileMoves.Add(tileMove);
     }
     tileMove.Relative += relative;
     return tileMove;
 }
示例#6
0
    public float RecordBlockPushed(TileMove tile)
    {
        //centered point
        var cPt = this.transform.InverseTransformPoint(tile.transform.parent.TransformPoint(tile.GoalPosition));
        //zero indexed point

        var absx = Mathf.Abs(cPt.x * 100).Round();//these values should only ever be increments of .5, any further decimal place would be floating point error. need to compare them. this is more reliable than approximately()
        var absy = Mathf.Abs(cPt.y * 100).Round();
        var absz = Mathf.Abs(cPt.z * 100).Round();

        var ziPt = new Vector3(cPt.x + (Width + 1) / 2f, cPt.y + (Width + 1) / 2f, cPt.z + (Width + 1) / 2f);

        var rewardedPoints = 0f;


        //add 3-count for corners, 2-count for sides, 1 for nonintersecting positions, 6-count for center pieces if they exist
        //possibly plus the count of moves so far(occurrences in the table)

        //we should be starting out looking at a cube which sits in the -z range and moves in the positive z range
        if (absx + absy + absz == 0)
        {
            //center +6 - count
            rewardedPoints = 6 - blockPositions[ziPt.x.Round(), ziPt.y.Round(), ziPt.z.Round()].Count;
        }
        else if (absx == absy && absy == absz)
        {
            //corner +3 - count
            rewardedPoints = 3 - blockPositions[ziPt.x.Round(), ziPt.y.Round(), ziPt.z.Round()].Count;
        }
        else if ((absx == absy || absy == absz || absx == absz) &&
                 Mathf.Abs(Mathf.Round(tile.GoalPosition.x * 100)) != Mathf.Abs(Mathf.Round(tile.GoalPosition.z * 100)))
        {
            //side +2 - count
            rewardedPoints = 2 - blockPositions[ziPt.x.Round(), ziPt.y.Round(), ziPt.z.Round()].Count;
        }
        else
        {
            //non intersecting +1
            rewardedPoints = 1;
        }

        blockPositions[ziPt.x.Round(), ziPt.y.Round(), ziPt.z.Round()].Add(tile);


        return(rewardedPoints);
    }
示例#7
0
    public override IEnumerator DisplayAction(TileAction originTile)
    {
        tile       = originTile as TileMove;
        inProgress = true;
        if (tile.forward)
        {
            advanceContent.SetActive(true);
        }
        else
        {
            returnContent.SetActive(true);
        }
        while (inProgress)
        {
            yield return(null);
        }
        tile.IncrementScore();
        yield return(new WaitForSeconds(1));

        yield return(StartCoroutine(manager.PlayerMovement(STEPS, tile.forward, false)));

        manager.EndTurn();
    }