コード例 #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
ファイル: House.cs プロジェクト: iggyzuk/swords-and-forks
 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
ファイル: Peasant.cs プロジェクト: iggyzuk/swords-and-forks
    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
ファイル: Townhall.cs プロジェクト: iggyzuk/swords-and-forks
    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
ファイル: Commander.cs プロジェクト: iggyzuk/swords-and-forks
    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>());
 }
コード例 #10
0
    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();
 }
コード例 #14
0
 // Test suite setup
 public ChickenTestsFixture()
 {
     Hatchery = new Hatchery();
 }
コード例 #15
0
 public void InitTestCase()
 {
     _hatchery = new Hatchery();
 }
コード例 #16
0
 public void InitTestSuite()
 {
     _hatchery = new Hatchery();
 }