Ejemplo n.º 1
0
Archivo: Unit.cs Proyecto: ghrguse/ss
        public IEnumerator AttackRoutine(Tile targetTile, Unit targetUnit /*, AttackInstance attInstance*/)
        {
            while (!TurnControl.ClearToProceed())
            {
                yield return(null);
            }
            TurnControl.ActionCommenced();

            //play animation
            if (unitAnim != null)
            {
                unitAnim.Attack();
            }
            if (unitAudio != null)
            {
                unitAudio.Attack();
            }

            //TODO attack
            //target fight back?

            TurnControl.ActionCompleted(0.15f);
            while (!TurnControl.ClearToProceed())
            {
                yield return(null);
            }

            FinishAction();
        }
Ejemplo n.º 2
0
Archivo: Unit.cs Proyecto: ghrguse/ss
        public IEnumerator MoveRoutine(Tile targetTile)
        {
            tile.unit = null;

            byte[,] grid = TileManager.GetTiledMap().GetCostGrid(TileManager.TerrainToCost);
            List <Tile> path = AStar.SearchWalkableTile(grid, tile, targetTile);

            while (!TurnControl.ClearToProceed())
            {
                yield return(null);
            }

            TurnControl.ActionCommenced();

            if (unitAnim != null)
            {
                unitAnim.Move();
            }
            if (unitAudio != null)
            {
                unitAudio.Move();
            }


            while (path.Count > 0)
            {
                while (true)
                {
                    float dist = Vector3.Distance(transform.position, path[0].GetPos());
                    if (dist < 0.05f)
                    {
                        break;
                    }

                    //Quaternion wantedRot = Quaternion.LookRotation(path[0].GetPos() - transform.position);
                    //transform.rotation = Quaternion.Slerp(transform.rotation, wantedRot, Time.deltaTime * moveSpeed * 3);

                    unitAnim.Direction(path[0].GetPos().x - transform.position.x,
                                       path[0].GetPos().y - transform.position.y);
                    Vector3 dir = (path[0].GetPos() - transform.position).normalized;
                    transform.Translate(dir * Mathf.Min(moveSpeed * Time.deltaTime, dist), Space.World);
                    yield return(null);
                }

                tile = path[0];

                //FactionManager.UpdateHostileUnitTriggerStatus(this);

                path.RemoveAt(0);
            }

            if (unitAnim != null)
            {
                unitAnim.StopMove();
            }

            tile.unit          = this;
            transform.position = tile.GetPos();

            TurnControl.ActionCompleted(0.15f);

            BattleControl.UnlockUnitSelect();

            FinishAction();
        }