예제 #1
0
        /// <summary>
        /// Draws a tile.
        /// </summary>
        private static void DrawTile(Tile tile, Point2D start)
        {
            //A target location for 32x textures to be centered in the tile, without being enlarged.
            X32Target.X = start.X + 16;
            X32Target.Y = start.Y + 16;

            ComponentRenderer tileRenderer = tile.GetComponent <ComponentRenderer>();

            tileRenderer.Render(MapDrawer, start);

            TileItemTarget.X = start.X;
            TileItemTarget.Y = start.Y;

            DrawItems(tile, TileItemTarget);

            switch (tile.ImpendingAction)
            {
            case MagicalLifeAPI.Entity.AI.Task.ActionSelected.Mine:
                MapDrawer.Draw(AssetManager.Textures[AssetManager.NameToIndex[TextureLoader.GUIPickaxeMapIcon]], X32Target, RenderLayer.GUI);
                break;

            case MagicalLifeAPI.Entity.AI.Task.ActionSelected.Chop:
                MapDrawer.Draw(AssetManager.Textures[AssetManager.NameToIndex[TextureLoader.GUIAxeMapIcon]], X32Target, RenderLayer.GUI);
                break;

            default:
                //Do nothing.
                break;
            }
        }
예제 #2
0
    /// <summary> Should be called every frame </summary>
    /// <param name="pivot_point"> The pivot point, around which the camera turns </param>
    /// <param name="camera_transform"> The transform of the camera </param>
    public void UpdateDraw(Vector3 pivot_point, Transform camera_transform)
    {
        float mult      = Mathf.Min(Mathf.Max(40f, (pivot_point - camera_transform.position).magnitude) / 200f, 40f);
        float turr_mult = mult * .5f;

        map_drawer.Draw(new Polygon(100 * mult, 70, pivot_point, Vector3.up), mult);
        map_drawer.Draw(new Line(pivot_point - 120 * mult * Vector3.back, pivot_point + 120 * mult * Vector3.back), mult);
        map_drawer.Draw(new Line(pivot_point - 120 * mult * Vector3.left, pivot_point + 120 * mult * Vector3.left), mult);
        map_drawer.Draw(new Polygon(80 * mult, 50, pivot_point, Vector3.up), mult);
        map_drawer.Draw(new Line(pivot_point + 50 * mult * Vector3.up, pivot_point - 50 * mult * Vector3.up), mult);
        map_drawer.sprite_groups [1].ChangeShape(new Polygon(4, pivot_point, Vector3.up, pivot_point + Vector3.right * 130 * mult));

        var player = SceneGlobals.Player;

        foreach (TurretGroup tg in player.TurretGroups)
        {
            if (tg.Count > 0)
            {
                Vector3 tgtpos = tg.GetTgtDir(tg[0]);
                if (tgtpos.sqrMagnitude > 1e6f)
                {
                    tgtpos = tgtpos.normalized * 1000;
                }

                // Turret aiming lines
                foreach (Turret turr in tg.TurretArray)
                {
                    Line connection = new Line(turr.MidPos, turr.MidPos + tg.GetTgtDir(turr));
                    map_drawer.Draw(connection, new Color(.85f, .8f, .25f), turr_mult);
                }
            }
        }
    }
예제 #3
0
        private static void DrawItems(Tile tile, Rectangle target)
        {
            if (tile.Item != null)
            {
                Texture2D texture = AssetManager.Textures[tile.Item.TextureIndex];
                MapDrawer.Draw(texture, target, RenderLayer.Items);

                ItemCountBounds.X = target.Location.X + TileSize.X / 2;
                ItemCountBounds.Y = target.Location.Y + TileSize.Y;

                MapDrawer.DrawText(tile.Item.CurrentlyStacked.ToString(), ItemCountBounds,
                                   ItemCountFont, SimpleTextRenderer.Alignment.Left, RenderLayer.MapItemCount);
            }
        }
예제 #4
0
        public void OnDraw()
        {
            statusDrawer.Draw();

            if (Menu.Debug.DrawAbilities)
            {
                foreach (var evadableAbility in abilityUpdater.EvadableAbilities)
                {
                    evadableAbility.Draw();
                }
            }

            if (Menu.Debug.DrawMap)
            {
                MapDrawer.Draw(debugPath);
            }
        }
예제 #5
0
 public override void Draw()
 {
     GraphicsDevice.Clear(Color.Green);
     mapDrawer.Draw(SpriteBatch, camera);
     UserInterface.Active.Draw(SpriteBatch);
 }
예제 #6
0
    // Use this for initialization
    void Start()
    {
        // 맵 불러오기
        StageScript.Cleared = false;
        TextAsset json = configuration.activatedMapSource;

        if (json == null)
        {
            // 디버그용 (GameplayScene을 바로 플레이할 때)
            json = Resources.Load <TextAsset>("maps/map-1-1");
        }
        map = JsonConvert.DeserializeObject <Map>(json.text);

        // 맵 Scene에 그리기

        //CellDrawer : 한 셀
        //MapBlockDrawer : 그리드
        //MapDrawer : 나머지 전부
        var mapDrawer     = new MapDrawer(new MapBlockDrawer(new CellDrawer()));
        var mapGameObject = mapDrawer.Draw(map);

        mapGameObject.AddComponent <StageScript>();
        var stageScript = mapGameObject.GetComponent <StageScript>();


        stageScript.map = map;

        stageScript.mapAnimationController = new MapAnimationController(mapGameObject);

        //맵의 유리 정보 초기화
        map.GlassMap();
        //맵에서 사용가능한 스프링 개수 받아와서 할당
        SpringCount = map.springsAvailable;


        //UI 생성
        var uiPatternDrawer = new UIPatternDrawer(new UICellDrawer());
        var uiPattern       = uiPatternDrawer.Draw(map.pattern, map.pattern.Count());

        uiPattern.transform.SetParent(GameObject.Find("PatternRoot").transform);
        uiPattern.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0);
        uiPattern.name = "PatternUI";


        Text Tutorial = GameObject.Find("Tutorial").GetComponent <Text>();

        Tutorial.text = map.comment;



        //플레이어 생성 및 초기화
        player      = GameObject.Instantiate(Resources.Load <GameObject>("prefabs/player"));
        player.name = "Player";
        var playerScript = player.GetComponent <PlayerControlScript>();

        playerScript.stageRoot       = mapGameObject;
        playerScript.soundController = new PlayerSoundController(player);


        Invoke("Set_ItemValue", 0.2f);

        //스테이지 이름
        GameObject.Find("StageName").GetComponent <Text> ().text = configuration.mapName;
        GameObject.Find("Clear_Notification").GetComponent <ClearNotification> ().DisableClearNotification();

        itemVisualization();
    }