示例#1
0
 public MoveComponent(List <MapEvent.Actor> actors, ScrollCamera camera)
 {
     Commands      = new Dictionary <MapEvent.Actor, CharacterMoveCommand>();
     CameraCommand = new CharacterMoveCommand();
     Actors        = actors;
     MainCamera    = camera;
 }
示例#2
0
        private SoundManager sound;                      //サウンド管理者
        #region キャラクター管理者に委託
        //キャラクター関連
        //private Runner runner;
        //private FixedEnemy fixEnem;
        //private FlyingEnemy flying;
        #endregion

        /// <summary>
        /// コンストラクタ
        /// </summary>
        public GameScene()
        {
            camera         = new ScrollCamera();
            generalManager = new CharacterGenerateManager();
            score          = new Score();
            #region キャラクター生成・管理者に委託
            //fixEnem = new FixedEnemy();
            //flying = new FlyingEnemy();
            //runner = new Runner();
            #endregion
            isEndFlag = false;
        }
示例#3
0
        public static MoveComponent LoadMoveComponent(MoveComponentIO moveComponentIO, List <MapEvent.Actor> actors, ScrollCamera camera)
        {
            var component = new MoveComponent(actors, camera);

            component.Frame = moveComponentIO.Frame;
            foreach (var item in moveComponentIO.Commands)
            {
                component.Commands[actors.Where(obj => (obj.ActorObject.Path == null && obj.ActorObject.Path == item.Key.Path) ? true : obj.ActorObject.ID == item.Key.ID).First()]
                    = new CharacterMoveCommand()
                    {
                    MoveCommandElements = item.Value.MoveCommandElements.Select(obj => new Dictionary <Inputs, bool>(obj)).ToList()
                    };
            }
            if (moveComponentIO.CameraCommand != null)
            {
                component.CameraCommand = new CharacterMoveCommand()
                {
                    MoveCommandElements = moveComponentIO.CameraCommand.MoveCommandElements.Select(obj => new Dictionary <Inputs, bool>(obj)).ToList()
                }
            }
            ;

            return(component);
        }
示例#4
0
文件: MapLayer.cs 项目: gon6109/sat
        /// <summary>
        /// マップのロード
        /// </summary>
        /// <param name="mapIO">マップデータ</param>
        /// <param name="initDoorID">初期ドアID</param>
        /// <param name="initSavePointID">初期セーブポイント</param>
        /// <param name="loader">ロードするオブジェクト</param>
        /// <returns></returns>
        public async Task LoadMapData(SatIO.MapIO mapIO, int initDoorID, int initSavePointID, ILoader loader)
        {
            //背景
            foreach (var item in mapIO.BackGrounds)
            {
                var backGround = await BackGround.CreateBackGroudAsync(item);

                AddObject(backGround);
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
            }

            //物理世界構築
            PhysicalWorld = new PhysicalWorld(new asd.RectF(new asd.Vector2DF(-200, -200), mapIO.Size + new asd.Vector2DF(200, 200) * 2), new asd.Vector2DF(0, 8000));

            //カメラ設定
            {
                PlayerCamera = new ScrollCamera(mapIO.CameraRestrictions);
                PlayerCamera.HomingObject = Player;
                PlayerCamera.Src          = new asd.RectI(0, 0, (int)OriginDisplaySize.X, (int)OriginDisplaySize.Y);
                PlayerCamera.MapSize      = mapIO.Size;
                AddObject(PlayerCamera);

                Camera.IsDrawn   = false;
                Camera.IsUpdated = false;
            }

            //障害物
            foreach (var item in mapIO.CollisionBoxes)
            {
                PhysicalRectangleShape temp = new PhysicalRectangleShape(PhysicalShapeType.Static, PhysicalWorld);
                temp.Density     = 1;
                temp.Restitution = 0;
                temp.Friction    = 0;
                temp.DrawingArea = new asd.RectF(item.Position, item.Size);
                Obstacles.Add(temp);
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
#if DEBUG
                asd.GeometryObject2D geometryObject = new asd.GeometryObject2D();
                geometryObject.Shape           = temp;
                geometryObject.Color           = new asd.Color(0, 0, 255, 100);
                geometryObject.DrawingPriority = 2;
                AddObject(geometryObject);
#endif
            }

            foreach (var item in mapIO.CollisionTriangles)
            {
                PhysicalTriangleShape temp = new PhysicalTriangleShape(PhysicalShapeType.Static, PhysicalWorld);
                temp.Density     = 1;
                temp.Restitution = 0;
                temp.Friction    = 0;
                var i = 0;
                foreach (var vertex in item.vertexes)
                {
                    temp.SetPointByIndex(vertex, i);
                    i++;
                }
                Obstacles.Add(temp);
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
#if DEBUG
                asd.GeometryObject2D geometryObject = new asd.GeometryObject2D();
                geometryObject.Shape           = temp;
                geometryObject.Color           = new asd.Color(0, 0, 255, 100);
                geometryObject.DrawingPriority = 2;
                AddObject(geometryObject);
#endif
            }

            //ドア
            var tempDoors = new List <Door>();
            foreach (var item in mapIO.Doors)
            {
                var door = await Door.CreateDoorAsync(item);

                door.OnLeave += OnLeave;
                AddObject(door);
                tempDoors.Add(door);
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
            }

            //マップオブジェクト
            foreach (var item in mapIO.MapObjects)
            {
                try
                {
                    var mapObject = await MapObject.CreateMapObjectAsync(item);

                    AddObject(mapObject);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
            }

            //イベントオブジェクト
            List <IActor> actors = new List <IActor>(GameScene.Players);
            foreach (var item in mapIO.EventObjects)
            {
                try
                {
                    var eventObject = await EventObject.CreateEventObjectAsync(item);

                    AddObject(eventObject);
                    actors.Add(eventObject);
                }
                catch (Exception e)
                {
                    Logger.Error(e);
                }
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
            }

            //イベント
            if (Scene is GameScene gameScene)
            {
                foreach (var item in mapIO.MapEvents)
                {
                    if (GameScene.EndEvents.Any(obj => obj.Key == gameScene.MapPath && obj.Value == item.ID))
                    {
                        continue;
                    }
                    try
                    {
                        bool isSkip = false;
                        foreach (var item2 in item.Actors.Where(obj => obj.Path != null && obj.Path.IndexOf(".pc") > -1))
                        {
                            if (!gameScene.CanUsePlayers.Any(obj => obj.Path == item2.Path))
                            {
                                isSkip = true;
                                break;
                            }
                        }
                        if (isSkip)
                        {
                            continue;
                        }
                        Object.MapEvent.MapEvent temp = await Object.MapEvent.MapEvent.CreateMapEventAsync(item, actors, PlayerCamera);

                        AddObject(temp);
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e);
                    }
                    loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
                }
            }

            //セーブポイント
            List <SavePoint> tempSavePoints = new List <SavePoint>();
            foreach (var item in mapIO.SavePoints)
            {
                SavePoint savePoint = new SavePoint(item);
                AddObject(savePoint);
                tempSavePoints.Add(savePoint);
                loader.ProgressInfo = (loader.ProgressInfo.taskCount, loader.ProgressInfo.progress + 1);
            }

            //プレイヤー初期配置
            if (initSavePointID != -1 && tempSavePoints.FirstOrDefault(savePoint => savePoint.ID == initSavePointID) != null)
            {
                Player.Position = tempSavePoints.FirstOrDefault(savePoint => savePoint.ID == initSavePointID).Position;
            }
            else if (initDoorID != -1 && tempDoors.FirstOrDefault(door => door.ID == initDoorID) != null)
            {
                Door door = tempDoors.FirstOrDefault(obj => obj.ID == initDoorID);
                Player.Position = door.Position;
                door.Come();
            }

            return;
        }
示例#5
0
 void Awake()
 {
     Instance = this;
 }
示例#6
0
    // Use this for initialization
    void Start()
    {
        Time.timeScale=1;
        //PlayerPrefs.DeleteAll();
        /*if (PlayerPrefs.HasKey(GlobalPrefs.totalJewels)){
            Globals.jewels=PlayerPrefs.GetInt(GlobalPrefs.totalJewels);
        }*/

        cantLevels=Format.countLevels();
        Vector3 position=new Vector3(0,0,0);

        levelInfo = new LevelInfo[cantLevels+1];
        list=new GameObject[cantLevels+1];

        for (int z=0;z<cantLevels;++z){
            position.x+=3;
            list[z]=(GameObject)GameObject.Instantiate(level,position,Quaternion.identity);
            Level l=list[z].GetComponent<Level>();
            l.level=z;
            levelInfo[z]=new LevelInfo();
            if (PlayerPrefs.HasKey(GlobalPrefs.getLevelBestTime(z))){
                levelInfo[z].bestTime=PlayerPrefs.GetFloat(GlobalPrefs.getLevelBestTime(z));
                levelInfo[z].bestTotal=PlayerPrefs.GetInt(GlobalPrefs.getLevelBestTotal(z));
                levelFollowing=z;
                levelInfo[z].played=true;
            }else{
                list[z].GetComponent<SpriteRenderer>().color=locked;
                levelInfo[z].played=false;
            }
        }
        if (++levelFollowing>=cantLevels)
            --levelFollowing;
        list[levelFollowing].GetComponent<SpriteRenderer>().color=ready;
        ubicFollowing=list[levelFollowing].transform.position;

        cam=Camera.main.GetComponent<ScrollCamera>();

        if (PlayerPrefs.HasKey(GlobalPrefs.lastLevelPlayed)){
            index=PlayerPrefs.GetInt(GlobalPrefs.lastLevelPlayed);
        }
        selectTarget(index);

        if (PlayerPrefs.HasKey(GlobalPrefs.volumeMusic)){
            AudioListener.volume=PlayerPrefs.GetFloat(GlobalPrefs.volumeMusic);
        }
        if (PlayerPrefs.HasKey(GlobalPrefs.qualityLevel)){
            QualitySettings.SetQualityLevel(PlayerPrefs.GetInt(GlobalPrefs.qualityLevel));
        }
    }