Пример #1
0
    private IEnumerator MakeGame()
    {
        Camera.main.clearFlags = CameraClearFlags.Skybox;
        Camera.main.rect       = new Rect(0f, 0f, 1f, 1f);
        maze = Instantiate(mazePrefab) as Maze;
        maze.gameController = this;
        yield return(StartCoroutine(maze.Generate()));

        player = Instantiate(playerPrefab) as Player;
        occupiedCoords.Add(maze.RandomCoord());
        player.SetLocation(maze.GetCell(occupiedCoords[0]));
        patrolFactory = gameObject.GetComponent <PatrolFactory>();
        patrols       = new List <Patrol>();
        for (int i = 0; i < 3; i++)
        {
            Patrol patrol = patrolFactory.Generate(maze);
            patrol.centerCoord = maze.RandomOtherCoord(occupiedCoords);
            //Debug.Log("patrol init coord: " + patrol.centerCoord);
            occupiedCoords.Add(patrol.centerCoord);
            patrol.SetLocation(maze.GetCell(patrol.centerCoord));
            if (patrol.currentCell.room != player.currentCell.room)
            {
                patrol.gameObject.SetActive(false);
            }
            patrols.Add(patrol);
        }
        Camera.main.clearFlags = CameraClearFlags.Depth;
        Camera.main.rect       = new Rect(0f, 0f, 0.5f, 0.5f);
    }
Пример #2
0
 public AbstractActorFactory getInstance()
 {
     if (instance == null)
     {
         instance = new PatrolFactory();
     }
     return(instance);
 }
Пример #3
0
 public static PatrolFactory getInstance()
 {
     if (_instance == null)
     {
         _instance = new PatrolFactory();
     }
     return(_instance);
 }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     Factory       = Singleton <PatrolFactory> .Instance;
     ActionManager = Singleton <CCActionManager> .Instance;
     LoadPatrol();
     //OnStartServer();
     Debug.Log("1");
 }
Пример #5
0
 //实例化组件,加载资源
 void Start()
 {
     Director.getInstance().sceneController = this;
     patrol_factory = Singleton <PatrolFactory> .Instance;
     action_manager = (PatrolActionManager)gameObject.AddComponent <PatrolActionManager>();
     recorder       = Singleton <ScoreRecorder> .Instance;
     load();
 }
Пример #6
0
    // Use this for initialization
    void Start()
    {
        gameOver      = 0;
        patrolFactory = PatrolFactory.getInstance();
        LoadResources();
        this.transform.parent = player.transform;

        Patrol.hitPlayerEvent += Over;
    }
Пример #7
0
 public void LoadResources()
 {
     Instantiate(Resources.Load <GameObject>("Prefabs/Maze"));
     action_manager = Singleton <PatrolActionManager> .Instance;
     patrol_factory = Singleton <PatrolFactory> .Instance;
     userGUI        = Singleton <UserGUI> .Instance;
     recorder       = Singleton <ScoreRecorder> .Instance;
     player         = Instantiate(Resources.Load("Prefabs/Player"), new Vector3(9, 9, -7), Quaternion.identity) as GameObject;
     patrols        = patrol_factory.GetPatrols();
 }
Пример #8
0
 public static PatrolFactory getInstance()
 {
     if (_instance == null)
     {
         _instance      = new PatrolFactory();
         _instance.used = new List <GameObject>();
         _instance.free = new List <GameObject>();
     }
     return(_instance);
 }
Пример #9
0
    void Awake()
    {
        SSDirector director = SSDirector.getInstance();

        director.currentScenceController = this;
        patrolFactory = Singleton <PatrolFactory> .Instance;
        LoadResources();
        gameState = GameState.BEGIN;
        PatrolCollide.catchSuccess += Gameover;
        scoreRecorder = Singleton <ScoreRecorder> .Instance;
    }
Пример #10
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance      = Singleton <PatrolFactory> .Instance;
         _instance.used = new List <GameObject>();
         _instance.free = new List <GameObject>();
         patrolPrefab   = Instantiate(Resources.Load <GameObject>("Prefabs/patrol"), new Vector3(348, 15, 324), Quaternion.identity);
     }
     Debug.Log("instance: " + _instance);
 }
Пример #11
0
    void Awake()
    {
        Director director = Director.getInstance();

        director.currentSceneController = this;
        judger              = gameObject.AddComponent <Judger>();
        patrolFactory       = gameObject.AddComponent <PatrolFactory>();
        playerArea          = 5;
        patrolActionManager = gameObject.AddComponent <PatrolActionManager>();
        gameObject.AddComponent <GameEventManager>();
        ui = gameObject.AddComponent <UI>() as UI;
    }
Пример #12
0
    private void Awake()
    {
        SSDirector director = SSDirector.getInstance();

        director.setFPS(60);
        director.currentSceneController = this;
        this.gameObject.AddComponent <PatrolFactory>();
        pf = Singleton <PatrolFactory> .Instance;
        this.gameObject.AddComponent <UserGUI>();
        director.currentSceneController.GenGameObjects();
        this.gameObject.AddComponent <CCActionManager>();
    }
Пример #13
0
    // Use this for initialization
    void Start()
    {
        SSDirector director = SSDirector.getInstance();

        director.currentSceneController = this;
        patrolFactory  = Singleton <PatrolFactory> .Instance;
        crystalFactory = Singleton <CrystalFactory> .Instance;
        actionManager  = gameObject.AddComponent <PatrolActionManager>() as PatrolActionManager;
        LoadResources();
        mainCamera.GetComponent <CameraMan>().target = player;
        scoreController = Singleton <ScoreController> .Instance;
    }
Пример #14
0
    public void CreatePatrols()
    {      //创建游戏开始时的巡逻兵
        PatrolFactory pf = PatrolFactory.getInstance();

        for (int i = 1; i <= 12; i++)
        {
            GameObject patrol = pf.getPatrol();
            patrol.name = "ZomBear" + ++bearNum;
            Handle p = patrol.GetComponent <Patrol>();
            sub.Attach(p);
            patrol.GetComponent <Patrol>().register(GetComponent <ScoreManager>().addScore);
        }
    }
Пример #15
0
    void Awake()
    {
        SSDirector director = SSDirector.GetInstance();

        director.CurrentScenceController = this;
        df = Singleton <PatrolFactory> .Instance;
        director.CurrentScenceController.LoadResources();
        gamestate = GameState.RUNNING;
        score     = 0;

        this.gameObject.AddComponent <UserGUI>();
        this.gameObject.AddComponent <GameEventManager>();
    }
Пример #16
0
    public void CreatePatrols()
    {
        PatrolFactory patrolFactory = Singleton <PatrolFactory> .Instance;

        for (int i = 0; i < 6; i++)
        {
            GameObject patrol = patrolFactory.getPatrol();
            patrol.name = "Patrol" + i;
            sub         = player.GetComponent <Player>();
            sub.AddListener(patrol.GetComponent <Patrol>());
            patrol.GetComponent <Patrol>().register(GetComponent <ScoreRecorder>().addScore);
        }
    }
    private int gameJudge;     // 0-> ingame, 1-> win, -1->lose
    // public GameObject collider1;
    // Use this for initialization
    void Awake()
    {
        //Debug.Log("FPS " + Application.targetFrameRate);
        Application.targetFrameRate = 30;
        SSDirector director = SSDirector.GetInstance();

        director.currentSceneController = this;
        patrolFactory = Singleton <PatrolFactory> .Instance;
        actionManager = gameObject.AddComponent <CCActionManager>() as CCActionManager;
        userGUI       = gameObject.AddComponent <UserGUI>() as UserGUI;
        timer         = gameObject.AddComponent <Timer>() as Timer;
        LoadResources();
    }
Пример #18
0
    Vector3 IniPos = Vector3.zero; //初始位置
    void Awake()
    {
        PatrolFactory patrolFactory = Singleton <PatrolFactory> .Instance; //patrol工厂单例

        patrol = patrolFactory.getPatrol();                                //生产patrol
        patrol.setParent(this.gameObject, IniPos);
        patrol.setCheckerWorldLoc(this.transform.position);
        //score预制的实例化,位置的初始化
        score = Object.Instantiate(Resources.Load("Prefabs/score"), Vector3.zero, Quaternion.identity) as GameObject;
        score.transform.parent        = this.gameObject.transform;
        score.transform.localPosition = Vector3.zero;
        score.name = "score" + this.gameObject.name.Substring(7);
    }
Пример #19
0
 void Awake()
 {
     LoadResources();
     factory = Singleton <PatrolFactory> .Instance;
     score   = ScoreRecorder.getInstance();
     list    = factory.getPatrolmans();
     Instantiate(Resources.Load("Prefabs/Plane"), new Vector3(0, 0, 0), Quaternion.identity);
     cam    = Camera.main;
     player = Instantiate(Resources.Load("Prefabs/player"), new Vector3(0, 0, 7), Quaternion.identity) as GameObject;
     cam.transform.parent           = player.transform;
     cam.transform.position         = new Vector3(0, 5, 0);
     cam.transform.localEulerAngles = new Vector3(40, 0, 0);
     Enable();
 }
Пример #20
0
    // Use this for initialization
    void Start()
    {
        record           = new ScoreRecorder();
        record.scoreText = scoreText;
        UI            = new UserGUI();
        UI.centerText = centerText;

        factory = Singleton <PatrolFactory> .Instance;

        //订阅者添加事件
        Publish publisher = Publisher.getInstance();

        publisher.add(this);
    }
Пример #21
0
    void Awake()
    {
        SSDirector director = SSDirector.getInstance();

        director.currentSceneController = this;
        patrolFactory = PatrolFactory.patrolFactory;
        actionManager = gameObject.AddComponent <CCActionManager>();
        LoadResources();

        if (player.GetComponent <Rigidbody>())
        {
            player.GetComponent <Rigidbody>().freezeRotation = true;
        }
    }
Пример #22
0
    void Awake()
    {
        LoadResources();
        factory = Singleton <PatrolFactory> .Instance;
        score   = ScoreRecorder.getInstance();
        list    = factory.getPatrolmans();
        //Instantiate(Resources.Load("Prefabs/Plane"), new Vector3(0, 0, 0), Quaternion.identity);
        player = this.gameObject;
        //cam = Instantiate(Cam);

        //cam.transform.position = new Vector3(0, 5, -7);
        //cam.transform.localEulerAngles = new Vector3(45, 0, 0);
        // cam.transform.parent = this.gameObject.transform;
        Enable();
    }
Пример #23
0
    void Awake()
    {
        //请记分员
        scorekeeper = Scorekeeper.getInstance();
        scorekeeper.sceneController = this;
        //请patrol工厂
        patrolFactory = PatrolFactory.getInstance();
        patrolFactory.sceneController = this;
        //导演
        SSDirector director = SSDirector.getInstance();

        director.setFPS(60);
        director.currentSceneController = this;
        director.currentSceneController.LoadResources();
    }
Пример #24
0
 void genPatrols()   //get patrols
 {
     patrolList       = new List <GameObject>(6);
     patrolRemainList = new List <int>(6);
     Vector3[] posSet = PatrolFactory.getInstance().getPosSet();
     for (int i = 0; i < 6; i++)
     {
         GameObject newPatrol = PatrolFactory.getInstance().getPatrol();
         newPatrol.transform.position = posSet[i];
         newPatrol.name = "Patrol" + i;
         patrolRemainList.Add(-2);
         patrolList.Add(newPatrol);
         addRandomMovement(newPatrol, true);
     }
 }
Пример #25
0
 //生产巡逻兵
 void genPatrols()
 {
     PatrolSet     = new List <GameObject>(6);
     PatrolLastDir = new List <int>(6);
     Vector3[] posSet = PatrolFactory.getInstance().getPosSet();
     for (int i = 0; i < 4; i++)
     {
         GameObject newPatrol = PatrolFactory.getInstance().getPatrol();
         newPatrol.transform.position = posSet[i];
         newPatrol.name = "Patrol" + i;
         PatrolLastDir.Add(-2);
         PatrolSet.Add(newPatrol);
         addRandomMovement(newPatrol, true);
     }
 }
Пример #26
0
 // treasure
 void Start()
 {
     maze     = Object.Instantiate(Resources.Load <GameObject>("maze"), Vector3.zero, Quaternion.identity);
     treasure = Object.Instantiate(Resources.Load <GameObject>("treasure_chest"), Vector3.zero, Quaternion.identity);
     player   = gameObject.AddComponent <Player>() as Player;
     userGUI  = gameObject.AddComponent <UserGUI>() as UserGUI;
     director = SSDirector.getInstance();
     director.currentSceneController = this;
     patrolFactory = new PatrolFactory();
     actionManager = gameObject.AddComponent <PatrolManager>() as PatrolManager;
     for (int i = 0; i < 9; i++)
     {
         actionManager.PatrolAround(patrolFactory.getPatrol(i));
     }
     initTreasure();
 }
Пример #27
0
    public int coinNumberGet   = 0;                                      // 玩家已收集硬币数量

    private void Awake()
    {
        SSDirector director = SSDirector.GetInstance();

        director.CurrentSceneController = this;

        patrolsFactory = Singleton <PatrolFactory> .Instance;
        coinFactory    = Singleton <CoinFactory> .Instance;
        scoreRecorder  = Singleton <ScoreRecorder> .Instance;
        actionManager  = gameObject.AddComponent <PatrolActionManager>() as PatrolActionManager;
        userGUI        = gameObject.AddComponent <UserGUI>() as UserGUI;
        timeManager    = gameObject.AddComponent <TimeManager>() as TimeManager;

        director.CurrentSceneController.LoadResource();
        gameOver = false;
    }
Пример #28
0
    //public Camera cameraMain;

    void Start()
    {
        SSDirector director = SSDirector.getInstance();

        director.CurrentSceneController = this;
        scoreRecorder       = Singleton <ScoreRecorder> .Instance;
        patrolFactory       = Singleton <PatrolFactory> .Instance;
        playerRegion        = 4;
        patrolActionManager = gameObject.AddComponent <PatrolActionManager>();
        userGUI             = gameObject.AddComponent <UserGUI>() as UserGUI;
        LoadResources();
        for (int i = 0; i < patrols.Count; ++i)
        {
            patrolActionManager.Patrol(patrols[i]);
        }
    }
Пример #29
0
 // Use this for initialization
 void Start()
 {
     director        = Director.getInstance();
     factory         = Singleton <PatrolFactory> .Instance;
     board           = Singleton <ScoreBoard> .Instance;
     director.scence = this;
     manager         = gameObject.AddComponent <PatrolActionManager>() as PatrolActionManager;
     gameObject.GetComponent <PatrolActionManager> ().player = player;
     for (int i = 0; i < 10; i++)
     {
         GameObject monster = factory.getPatrol(i / 2);
         monsters.Add(monster);
         manager.beginPatrol(monster);
     }
     getLocations(5);
     reloadSource();
 }
Пример #30
0
 void createPatrols()
 {
     PatrolList      = new List <GameObject>(6);
     PatrolDirection = new List <int>(6);
     Vector3[] locations = PatrolFactory.getInstance().getPatrolLocations();
     for (int i = 0; i < 6; i++)
     {
         //使用工厂模式初始化游戏对象
         GameObject newPatrol = PatrolFactory.getInstance().getPatrol();
         newPatrol.transform.position = locations[i];
         newPatrol.name = "Patrol" + i;
         //初始化巡逻方向为空
         PatrolDirection.Add(-2);
         PatrolList.Add(newPatrol);
         //开始让巡逻兵随机移动
         moveRandomly(newPatrol, true);
     }
 }