예제 #1
0
    public void OnPointerClick(PointerEventData eventData)
    {
        Commander com = Controller.Instance.commanders[CommanderID.Player];

        if (com.building != Building.None)
        {
            com.TryBuild(Builder.BuildingToEntity(com.building), pos.x, pos.y);
            com.building = Building.None;

            Controller.Instance.UI.Buttons.EnableAll();
        }
        else if (entity != null && entity.comID == CommanderID.Player)
        {
            int price = entity.GetPrice() * entity.level;
            if (price <= com.lumber)
            {
                Hatchery.SpawnEffect(pos.x, pos.y, Config.colors.purple);

                entity.level++;
                Level = entity.level;

                Task.Run().Time(0.03f).Random(0.015f).Loop(price).OnRepeat(_ =>
                {
                    Controller.Instance.UI.AddResourceBit(
                        Resource.Lumber,
                        Controller.Instance.UI.Lumber.position,
                        this.transform.position,
                        () => Controller.Instance.commanders[CommanderID.Player].RemoveLumber()
                        );
                });
            }
        }
    }
예제 #2
0
    void Awake()
    {
        hirePeasant.onClick.AddListener(() =>
        {
            Commander com = Controller.Instance.commanders[CommanderID.Player];

            if (Config.prices.peasant <= com.wheat)
            {
                Tile t = Controller.Instance.grid.FindClosestTileWithEntity <Townhall>(new Pos(), CommanderID.Player);
                Hatchery.SpawnPeasant(t.pos.x, t.pos.y, CommanderID.Player);

                Task.Run().Time(0.03f).Random(0.015f).Loop(Config.prices.peasant).OnRepeat(_ =>
                {
                    Controller.Instance.commanders[CommanderID.Player].RemoveWheat();

                    Controller.Instance.UI.AddResourceBit(
                        Resource.Wheat,
                        Controller.Instance.UI.Wheat.position,
                        t.transform.position,
                        () => { }
                        );
                });
            }
        });

        constructHouse.onClick.AddListener(() => StartBuilding(Building.House));
        constructLumberyard.onClick.AddListener(() => StartBuilding(Building.Lumberyard));
        constructWindmill.onClick.AddListener(() => StartBuilding(Building.Windmill));
        constructTower.onClick.AddListener(() => StartBuilding(Building.Tower));
        constructCastle.onClick.AddListener(() => StartBuilding(Building.Castle));
    }
예제 #3
0
 public override void Init()
 {
     updateTask = Task.Run().Time(15).Random(15).Loop(-1).OnRepeat(_ =>
     {
         if (peasant == null)
         {
             peasant = Hatchery.SpawnPeasant(tile.pos.x, tile.pos.y, comID);
         }
     });
 }
예제 #4
0
    public void Init(int x, int y, CommanderID comID)
    {
        pos.x = x;
        pos.y = y;

        this.comID = comID;

        body.color = Controller.Instance.commanders[comID].color;

        resourceImage.enabled = false;

        List <Pos> path = new List <Pos>();

        updateTask = Task.Run().Name("Peasant(tick)").Loop(-1).OnRepeat(t =>
        {
            if (movementTask != null)
            {
                return;
            }

            if (path.Count > 0)
            {
                MoveTo(path[0]);
                path.RemoveAt(0);
                return;
            }

            path = PickNextPath();

            if (path.Count > 0)
            {
                MoveTo(path[0]);
                path.RemoveAt(0);
                return;
            }

            MoveToRandomNeighbour();

            if (!isActive)
            {
                Core.Juggler.Remove(updateTask);
                if (movementTask != null)
                {
                    Core.Juggler.Remove(movementTask);
                }
                Object.Destroy(this.gameObject);

                Hatchery.SpawnEffect(pos.x, pos.y, Config.colors.pink);
            }
        });
    }
예제 #5
0
파일: World.cs 프로젝트: jei-W/duckFarm
    //오리 생성함수
    public void OnHatchEggInHatchery(Hatchery hatchery, Egg egg)
    {
        Debug.Log("삐약");

        GameObject objectBase = Instantiate(Resources.Load("Prefabs/duck"), hatchery.transform.position, Quaternion.identity) as GameObject;
        string     objectID   = $"duck_{s_duckUniqueID++}";
        Duck       duckling   = objectBase.GetComponent <Duck>();

        duckling.ObjectID = objectID;
        duckling.male     = egg.male;
        duckling.name     = objectID;

        ducksList.Add(objectID, duckling);

        foodsList.Remove(egg.ObjectID);
        GameObject.Destroy(egg.gameObject);
        eggCount--;
    }
예제 #6
0
    public override void Init()
    {
        Hatchery.SpawnPeasant(tile.pos.x, tile.pos.y, comID);

        lumberProductionTask = Task.Run().Name("Townhall(produce)").Time(25f - Mathf.Clamp(level, 0, 20)).Loop(-1).OnRepeat(_ =>
        {
            if (comID == CommanderID.Player)
            {
                Task.Run().Time(0.03f).Random(0.015f).Loop(level).OnRepeat(__ =>
                {
                    Controller.Instance.UI.AddResourceBit(
                        Resource.Lumber,
                        tile.transform.position,
                        Controller.Instance.UI.Lumber.position,
                        () => Controller.Instance.commanders[comID].AddLumber()
                        );
                });
            }
            else
            {
                Controller.Instance.commanders[comID].AddLumber(level);
            }
        });

        wheatProductionTask = Task.Run().Time(10f - Mathf.Clamp(level, 0, 8)).Loop(-1).OnRepeat(_ =>
        {
            if (comID == CommanderID.Player)
            {
                Task.Run().Time(0.03f).Random(0.015f).Loop(level).OnRepeat(__ =>
                {
                    Controller.Instance.UI.AddResourceBit(
                        Resource.Wheat,
                        tile.transform.position,
                        Controller.Instance.UI.Wheat.position,
                        () => Controller.Instance.commanders[comID].AddWheat()
                        );
                });
            }
            else
            {
                Controller.Instance.commanders[comID].AddWheat(level);
            }
        });
    }
예제 #7
0
    /// <summary>
    /// Create a new egg to hatch
    /// </summary>
    public void CreateNewEgg()
    {
        attributes.text = "No attributes yet.";
        HatcheryTypes randHatchery = (HatcheryTypes)Random.Range(0, 3);

        switch (randHatchery)
        {
        case HatcheryTypes.AVIAN:
            hatchery = new AvianHatchery();
            eggImage.GetComponent <Image>().color = Color.blue;
            break;

        case HatcheryTypes.MAMMAL:
            hatchery = new MammalHatchery();
            eggImage.GetComponent <Image>().color = Color.red;
            break;

        case HatcheryTypes.REPTILE:
            hatchery = new ReptileHatchery();
            eggImage.GetComponent <Image>().color = Color.green;
            break;
        }
    }
예제 #8
0
    public bool TryBuild(Entity entity, int x, int y)
    {
        entity.comID = comID;

        if (entity.GetPrice() <= lumber)
        {
            Tile tile = Builder.Build(entity, x, y);
            if (tile != null)
            {
                lumber -= entity.GetPrice();

                tile.Border = color;
                tile.SetEntityColor(color);

                Hatchery.SpawnEffect(x, y, Config.colors.white);
            }

            Controller.Instance.UI.UpdateLumber();

            return(true);
        }
        return(false);
    }
예제 #9
0
 public static IWebHostBuilder CreateWebHostBuilder(string[] args)
 {
     return(WebHost.CreateDefaultBuilder(args)
            .ConfigureServices(services =>
     {
         services.AddSingleton <IClusterClient>(sp => ConnectClient().Result);
         services.AddSingleton <RPC.HatcheryFacade, RPC.HatcheryFacade>();
         services.AddSingleton <SubscriberFacade, SubscriberFacade>();
         services.AddSingleton <LoggingInterceptor, LoggingInterceptor>();
         // TODO: Find a better way to indicate that these are brokers. OR
         // TODO: Load brokers from appsettings.json
         services.AddSingleton <IEnumerable <string> >(sp => new List <string>()
         {
             "127.0.0.1:9092"
         });
         services.AddSingleton <IEnumerable <Server> >(sp =>
         {
             var hatcheryService = Hatchery.BindService(sp.GetService <RPC.HatcheryFacade>());
             var subscriberService = Subscriber.BindService(sp.GetService <SubscriberFacade>());
             var loggingInterceptor = sp.GetRequiredService <LoggingInterceptor>();
             return new List <Server>()
             {
                 new Server()
                 {
                     Services =
                     {
                         hatcheryService.Intercept(loggingInterceptor),
                         subscriberService.Intercept(loggingInterceptor),
                     },
                     Ports = { new ServerPort("0.0.0.0", 9998, ServerCredentials.Insecure) }
                 }
             };
         });
         services.AddSingleton <IHostedService, GrpcBackgroundService>();
     })
            .UseStartup <Startup>());
 }
    protected virtual void OnSceneGUI()
    {
        Hatchery hatchery = (Hatchery)target;

        // copy the target object's data to the handle
        m_BoundsHandle.center = hatchery.transform.position;
        m_BoundsHandle.size   = hatchery.Extents;
        // draw the handle
        EditorGUI.BeginChangeCheck();
        m_BoundsHandle.DrawHandle();

        if (EditorGUI.EndChangeCheck())
        {
            // record the target object before setting new values so changes can be undone/redone
            Undo.RecordObject(target, "Change Hatchery Bounds");

            // copy the handle's updated data back to the target object
            Bounds newBounds = new Bounds();
            newBounds.center = m_BoundsHandle.center;
            newBounds.size   = m_BoundsHandle.size;
            hatchery.bounds  = newBounds;
            hatchery.Extents = newBounds.size;
        }
    }
예제 #11
0
 // Gets called every time, but fixture is built once for the whole suite
 public ChickenTests(ChickenTestsFixture fixture)
 {
     _hatchery = fixture.Hatchery;
 }
예제 #12
0
 public static void SetupTestSuite(TestContext context)
 {
     _hatchery = new Hatchery();
 }
예제 #13
0
 public void SetupTestCase()
 {
     _hatchery = new Hatchery();
 }
 // Test suite setup
 public ChickenTestsFixture()
 {
     Hatchery = new Hatchery();
 }
예제 #15
0
 public void InitTestCase()
 {
     _hatchery = new Hatchery();
 }
예제 #16
0
 public void InitTestSuite()
 {
     _hatchery = new Hatchery();
 }