예제 #1
0
    public Game(ProcessManager manager) : base(manager, ProcessManager.ProcessID.Game)
    {
        this.nextIssuedId = UnityEngine.Random.Range(1000, 10000);

        //加载Demo配置文件
        this.LoadDemoConfigs();

        //初始化相机
        this.Camera = new RoomCamera(this);

        //初始化Demo房间
        this.Room = new Room(this);

        //相机聚焦房间
        this.Camera.MoveCamera(Room, 0);

        //根据Demo场景生成对应的生物
        if (Configs.Level == 1)
        {
            TentaclePlant plantDown = new TentaclePlant(new WorldEntity(new WorldCoordinate(26, 26), this.GetNewID()));
            plantDown.PlaceInRoom(Room);
            plantDown.ResetPlant(new Vector2(510, 110), Vector2.up);

            TentaclePlant plantRight = new TentaclePlant(new WorldEntity(new WorldCoordinate(26, 26), this.GetNewID()));
            plantRight.PlaceInRoom(Room);
            plantRight.ResetPlant(new Vector2(850, 350), Vector2.left);

            TentaclePlant plantLeft = new TentaclePlant(new WorldEntity(new WorldCoordinate(26, 26), this.GetNewID()));
            plantLeft.PlaceInRoom(Room);
            plantLeft.ResetPlant(new Vector2(110, 490), Vector2.right);
        }
        else
        {
            DaddyLongLegs daddy = new DaddyLongLegs(new WorldEntity(new WorldCoordinate(26, 26), this.GetNewID()));
            daddy.PlaceInRoom(Room);
            daddy.ResetCreature(new IntVector2(36, 5), Vector2.up);
        }
    }
    public override void Realize()
    {
        if (realizedCreature != null)
        {
            return;
        }
        switch (creatureTemplate.TopAncestor().type)
        {
        case CreatureTemplate.Type.Slugcat:
            realizedCreature = new Player(this, world);
            break;

        case CreatureTemplate.Type.LizardTemplate:
            realizedCreature = new Lizard(this, world);
            break;

        case CreatureTemplate.Type.Fly:
            realizedCreature = new Fly(this, world);
            break;

        case CreatureTemplate.Type.Leech:
            realizedCreature = new Leech(this, world);
            break;

        case CreatureTemplate.Type.Snail:
            realizedCreature = new Snail(this, world);
            break;

        case CreatureTemplate.Type.Vulture:
            realizedCreature = new Vulture(this, world);
            break;

        case CreatureTemplate.Type.GarbageWorm:
            GarbageWormAI.MoveAbstractCreatureToGarbage(this, Room);
            realizedCreature = new GarbageWorm(this, world);
            break;

        case CreatureTemplate.Type.LanternMouse:
            realizedCreature = new LanternMouse(this, world);
            break;

        case CreatureTemplate.Type.CicadaA:
            realizedCreature = new Cicada(this, world, creatureTemplate.type == CreatureTemplate.Type.CicadaA);
            break;

        case CreatureTemplate.Type.Spider:
            realizedCreature = new Spider(this, world);
            break;

        case CreatureTemplate.Type.JetFish:
            realizedCreature = new JetFish(this, world);
            break;

        case (CreatureTemplate.Type)patch_CreatureTemplate.Type.SeaDrake:
            realizedCreature = new SeaDrake(this, world);
            break;

        case CreatureTemplate.Type.BigEel:
            realizedCreature = new BigEel(this, world);
            break;

        case CreatureTemplate.Type.Deer:
            realizedCreature = new Deer(this, world);
            break;

        case (CreatureTemplate.Type)patch_CreatureTemplate.Type.WalkerBeast:
            realizedCreature = new WalkerBeast(this, world);
            break;

        case CreatureTemplate.Type.TubeWorm:
            realizedCreature = new TubeWorm(this, world);
            break;

        case CreatureTemplate.Type.DaddyLongLegs:
            realizedCreature = new DaddyLongLegs(this, world);
            break;

        case CreatureTemplate.Type.TentaclePlant:
            if (creatureTemplate.type == CreatureTemplate.Type.TentaclePlant)
            {
                realizedCreature = new TentaclePlant(this, world);
            }
            else
            {
                realizedCreature = new PoleMimic(this, world);
            }
            break;

        case CreatureTemplate.Type.MirosBird:
            realizedCreature = new MirosBird(this, world);
            break;

        case CreatureTemplate.Type.TempleGuard:
            realizedCreature = new TempleGuard(this, world);
            break;

        case CreatureTemplate.Type.Centipede:
        case CreatureTemplate.Type.RedCentipede:
        case CreatureTemplate.Type.Centiwing:
        case CreatureTemplate.Type.SmallCentipede:
            realizedCreature = new Centipede(this, world);
            break;

        case CreatureTemplate.Type.Scavenger:
            realizedCreature = new Scavenger(this, world);
            break;

        case CreatureTemplate.Type.Overseer:
            realizedCreature = new Overseer(this, world);
            break;

        case CreatureTemplate.Type.VultureGrub:
            if (creatureTemplate.type == CreatureTemplate.Type.VultureGrub)
            {
                realizedCreature = new VultureGrub(this, world);
            }
            else if (creatureTemplate.type == CreatureTemplate.Type.Hazer)
            {
                realizedCreature = new Hazer(this, world);
            }
            break;

        case CreatureTemplate.Type.EggBug:
            realizedCreature = new EggBug(this, world);
            break;

        case CreatureTemplate.Type.BigSpider:
        case CreatureTemplate.Type.SpitterSpider:
            realizedCreature = new BigSpider(this, world);
            break;

        case CreatureTemplate.Type.BigNeedleWorm:
            if (creatureTemplate.type == CreatureTemplate.Type.SmallNeedleWorm)
            {
                realizedCreature = new SmallNeedleWorm(this, world);
            }
            else
            {
                realizedCreature = new BigNeedleWorm(this, world);
            }
            break;

        case CreatureTemplate.Type.DropBug:
            realizedCreature = new DropBug(this, world);
            break;
        }
        InitiateAI();
        for (int i = 0; i < stuckObjects.Count; i++)
        {
            if (stuckObjects[i].A.realizedObject == null)
            {
                stuckObjects[i].A.Realize();
            }
            if (stuckObjects[i].B.realizedObject == null)
            {
                stuckObjects[i].B.Realize();
            }
        }
    }