Inheritance: MonoBehaviour
 void Awake()
 {
     if (instance == null)
         instance = this;
     else
         instance = null;
 }
Ejemplo n.º 2
0
 public Serf AddSerf(Vector2 position, ResourceController resController)
 {
     //Debug.Log(position.x + " " + position.y);
     Serf serf = new Serf(position, this, resController);
     GameObject unit_go = Instantiate(serf_prefab);
     unit_go.transform.SetParent(characters.transform);
     unit_go.transform.position = new Vector3(position.x, MapController.Instance.mapData.GetHeight(position) + 1f, position.y);
     unitList.Add(serf, unit_go);
     return serf;
 }
Ejemplo n.º 3
0
 private bool CanHarvest(JunklingSensor resource)
 {
     targetResource = resource.GetTileCollider().GetComponent<ResourceController>();
     string type = targetResource.GetTileType();
     if(type==TileTypes.ROCK && !canHarvestRock) return false;
     if(targetResource.IsSpawned())
     {
         StartHarvest();
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public void AddStore(ResourceController store)
 {
     if (!storeList.Contains(store))
     {
         storeList.Add(store);
         foreach(Order order in myOrders)
         {
             store.AddOrder(order, neededCount != 0);
             //Debug.Log("AddStore: order added");
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Reconstructs a permission with a specified state from an XML encoding.
        /// </summary>
        /// <param name="e">The XML encoding used to reconstruct the permission.</param>
        /// <exception cref="ArgumentNullException"><i>elem</i> is a null reference.</exception>
        /// <exception cref="ArgumentException"><i>elem</i> does not contain valid XML for this permission.</exception>
        public override void FromXml(SecurityElement e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("elem", ResourceController.GetString("Error_ParamNull"));
            }
            if (!e.Tag.Equals("IPermission") && !e.Tag.Equals("Permission"))
            {
                throw new ArgumentException(ResourceController.GetString("Error_NotAPermissionElement"));
            }
            string version = e.Attribute("version");

            if ((version != null) && !version.Equals("1"))
            {
                throw new ArgumentException(ResourceController.GetString("Error_InvalidXMLBadVersion"));
            }
            m_AllowedAtrs.Clear();
            string state      = e.Attribute("State");
            int    stateValue = 0;

            if (state == null || !int.TryParse(state, out stateValue))
            {
                m_Options = SmartcardConnectOption.None;
            }
            else
            {
                if (!Enum.IsDefined(typeof(SmartcardConnectOption), stateValue))
                {
                    throw new ArgumentException(ResourceController.GetString("Error_ParamInvalid"));
                }
                m_Options = (SmartcardConnectOption)stateValue;
            }
            if (m_Options == SmartcardConnectOption.AllowedAtrs)
            {
                foreach (SecurityElement se in e.Children)
                {
                    if (se != null && se.Tag.Equals("ATR"))
                    {
                        m_AllowedAtrs.AddLast(new Atr(Convert.FromBase64String(se.Attribute("Value")), Convert.FromBase64String(se.Attribute("Mask"))));
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void RefreshStatus()
        {
            IntPtr readerName;
            int    nameLength = NativeMethods.SCARD_AUTOALLOCATE;

            byte[] atrBuffer = new byte[32];
            int    atrLength = atrBuffer.Length;
            int    ret       = NativeMethods.SCardStatus(m_Card, out readerName, ref nameLength, out m_State, out m_ActiveProtocol, atrBuffer, ref atrLength);

            try {
                if (ret != NativeMethods.SCARD_S_SUCCESS || atrLength < 0)
                {
                    throw new SmartcardException(ResourceController.GetString("Error_SmartcardGetStatus"), ret);
                }
            } finally {
                NativeMethods.SCardFreeMemory(m_Context, readerName);
            }
            m_Atr = new Atr(atrBuffer, atrLength);
        }
Ejemplo n.º 7
0
        public ConfirmDeleteDialog(bool deleteFromRecycleBin, StorageDeleteOption deleteOption)
        {
            this.InitializeComponent();

            this.Result            = MyResult.Nothing; //clear the result in case the value is set from last time
            this.PermanentlyDelete = deleteOption;

            // If deleting from recycle bin disable "permanently delete" option
            this.chkPermanentlyDelete.IsEnabled = !deleteFromRecycleBin;

            if (SelectedItemsPropertiesViewModel.SelectedItemsCount == 1)
            {
                Description = ResourceController.GetTranslation("ConfirmDeleteDialogDeleteOneItem/Text");
            }
            else
            {
                Description = string.Format(ResourceController.GetTranslation("ConfirmDeleteDialogDeleteMultipleItems/Text"), SelectedItemsPropertiesViewModel.SelectedItemsCount);
            }
        }
Ejemplo n.º 8
0
    public override void Bind(Entity entity)
    {
        base.Bind(entity);
        ResourceDiff       ret;
        ResourceController controller = target.resourceController;

        for (int i = 0; i < controller.totals.Count; i++)
        {
            ret = pool.Count > 0 ? pool.Dequeue() : Instantiate(prefab, content);
            ret.Bind(controller.totals[i].type, controller.totals[i].prod, controller.totals[i].max);
            list.Add(ret);
        }
        for (int i = 0; i < controller.productions.Count; i++)
        {
            ret = pool.Count > 0 ? pool.Dequeue() : Instantiate(prefab, content);
            ret.Bind(controller.productions[i].type, controller.productions[i].prod, controller.productions[i].max);
            list.Add(ret);
        }
    }
Ejemplo n.º 9
0
        public async Task DeleteConfirmdedRedirectToCorrectAction_AfterDeleteHasBeenDone()
        {
            var deleteResourceQuery = new ResourceDeleteViewModel {
                Id = 1, CampaignId = 4, UserIsOrgAdmin = true
            };

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <DeleteResourceQuery>())).ReturnsAsync(It.IsAny <ResourceDeleteViewModel>());

            var sut    = new ResourceController(mockMediator.Object);
            var result = await sut.DeleteConfirmed(deleteResourceQuery) as RedirectToActionResult;

            result.ShouldNotBeNull();
            result.ActionName.ShouldBe(nameof(CampaignController.Details));
            result.ControllerName.ShouldBe("Campaign");
            result.RouteValues["area"].ShouldBe("Admin");
            result.RouteValues["id"].ShouldBe(deleteResourceQuery.CampaignId);
        }
Ejemplo n.º 10
0
    private void AddAllResources()
    {
        bool showResources = true;

        foreach (ResourceConfig config in ResourcesConfigs)
        {
            GameObject         obj      = Instantiate(ResourcePrefab.gameObject, ResourcesParent, false);
            ResourceController resource = obj.GetComponent <ResourceController>();

            resource.SetConfig(config);
            obj.gameObject.SetActive(showResources);

            if (showResources && !resource.IsUnlocked)
            {
                showResources = false;
            }
            _activeResources.Add(resource);
        }
    }
Ejemplo n.º 11
0
        public async Task PostAsync_Calls_Service()
        {
            // Arrange
            var resource    = new Resource();
            var serviceMock = new Mock <ICreateService <Resource> >();

            var controller = new ResourceController(new JsonApiOptions(), NullLoggerFactory.Instance, create: serviceMock.Object);

            serviceMock.Setup(m => m.CreateAsync(It.IsAny <Resource>(), It.IsAny <CancellationToken>())).ReturnsAsync(resource);
            controller.ControllerContext = new ControllerContext {
                HttpContext = new DefaultHttpContext()
            };

            // Act
            await controller.PostAsync(resource, CancellationToken.None);

            // Assert
            serviceMock.Verify(m => m.CreateAsync(It.IsAny <Resource>(), CancellationToken.None), Times.Once);
        }
Ejemplo n.º 12
0
    public static void Create(string name, string spritePath, Vector2 position, Vector2?scale = null, float rotation = 0, int order = 0)
    {
        var gameElement     = new GameObject(name);
        var spriteComponent = gameElement.AddComponent <SpriteRenderer>();
        var element         = gameElement.AddComponent <Element>();

        spriteComponent.sortingOrder = order;

        spriteComponent.sprite = ResourceController.Get <Sprite>(spritePath);


        element.Position = position;
        element.Scale    = scale ?? Vector2.one;
        element.Rotation = rotation;

        element.transform.SetParent(stage.transform);

        instances[name] = gameElement;
    }
Ejemplo n.º 13
0
    //Method that initializes the settings and data used in GameData.
    static public void Initialize()
    {
        LevelObjects = new GameObjectList();
        Buildings    = new GameObjectList(4);
        GameData.LevelObjects.Add(Buildings);
        Units = new GameObjectList(4);
        LevelObjects.Add(Units);
        Cursor = new Cursor();
        GameData.LevelObjects.Add(Cursor);
        if (GameData.SinglePlayer)
        {
            ResourceController r;

            r = new ResourceController(3, 5, 0);

            GameData.LevelObjects.Add(r);
        }
        forests = new List <Forest>();
    }
Ejemplo n.º 14
0
        public async Task EditPostSendsEditResourceCommandWithCorrectResource()
        {
            var mockMediator             = new Mock <IMediator>();
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 2, OrganizationId = 5, Name = "OrgName"
            };

            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);
            mockMediator.Setup(m => m.SendAsync(It.IsAny <CreateOrEditResourceCommand>())).ReturnsAsync(It.IsAny <int>());
            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());
            var resourceEditViewModel = new ResourceEditViewModel();

            var result = await sut.Edit(resourceEditViewModel) as RedirectToActionResult;

            result.ShouldNotBeNull();
            mockMediator.Verify(m => m.SendAsync(It.Is <CreateOrEditResourceCommand>(e => e.Resource == resourceEditViewModel)), Times.Once);
        }
Ejemplo n.º 15
0
        public static async void CreateFile(AddItemType fileType)
        {
            var    TabInstance = App.CurrentInstance;
            string currentPath = null;

            if (TabInstance.ContentPage != null)
            {
                currentPath = TabInstance.FilesystemViewModel.WorkingDirectory;
            }
            var folderWithPath = await Filesystem.ItemViewModel.GetFolderWithPathFromPathAsync(currentPath);

            StorageFolder folderToCreateItem = folderWithPath.Folder;
            RenameDialog  renameDialog       = new RenameDialog();

            var renameResult = await renameDialog.ShowAsync();

            if (renameResult != ContentDialogResult.Primary)
            {
                return;
            }

            var userInput = renameDialog.storedRenameInput;

            if (fileType == AddItemType.Folder)
            {
                userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewFolder");

                await folderToCreateItem.CreateFolderAsync(userInput, CreationCollisionOption.GenerateUniqueName);
            }
            else if (fileType == AddItemType.TextDocument)
            {
                userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewTextDocument");

                await folderToCreateItem.CreateFileAsync(userInput + ".txt", CreationCollisionOption.GenerateUniqueName);
            }
            else if (fileType == AddItemType.BitmapImage)
            {
                userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewBitmapImage");

                await folderToCreateItem.CreateFileAsync(userInput + ".bmp", CreationCollisionOption.GenerateUniqueName);
            }
        }
        public async Task EditPostReturnsUnauthorized_WhenUserIsNotOrganizationAdmin()
        {
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 4, OrganizationId = 1, Name = "TestCampaign"
            };

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserNotAnOrgAdmin();

            var result = await sut.Edit(new ResourceEditViewModel()) as UnauthorizedResult;

            result.ShouldNotBeNull();
            result.ShouldBeOfType <UnauthorizedResult>();
            result.StatusCode.ShouldBe((int)HttpStatusCode.Unauthorized);
        }
Ejemplo n.º 17
0
 public void SpreadDeitonBiome(Vertex v)
 {
     if (v.getBiome() == LOW_BIOME || v.getBiome() == OIL_BIOME || v.getBiome() == WATER_BIOME || v.getBiome() == STONE_BIOME)
     {
         v.setBiome(DEITON_BIOME);
         ResourceController resourceCont = (GameObject.FindObjectOfType(typeof(ResourceController)) as ResourceController);
         if (resourceCont != null)
         {
             resourceCont.DeitonMade(v);
         }
         Vertex[] neighbors = v.getNeighbors();
         for (int i = 0; i < neighbors.Length; i++)
         {
             if (neighbors[i].getHeight() < 0 && neighbors[i].getBiome() != STONE_BIOME)
             {
                 SpreadDeitonBiome(neighbors[i]);
             }
         }
     }
 }
        public async Task CreatePostReturnsView_IfModelStateIsNotValid()
        {
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 4, OrganizationId = 1, Name = "TestCampaign"
            };

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);

            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());
            sut.ModelState.AddModelError("Name", "Filling name is mandatory!");
            var result = await sut.Create(new ResourceEditViewModel()) as ViewResult;

            result.ShouldNotBeNull();
            result.ViewName.ShouldBe("Edit");
            result.Model.ShouldBeOfType <ResourceEditViewModel>();
        }
Ejemplo n.º 19
0
    public bool Execute(bool checkRequirements = true)
    {
        if (checkRequirements && !CheckRequirements())
        {
            return(false);
        }

        foreach (PolicyComponent component in GetComponents <PolicyComponent>())
        {
            component.Execute(this);
        }

        ResourceController rc = island.GetComponentInChildren <ResourceController>();

        rc.current.Subtract(resourceRequirements);
        rc.current.SetMin();
        rc.UpdateCurrentUI();

        return(true);
    }
Ejemplo n.º 20
0
 public void SandAtIndex(int index)
 {
     if (vertices[index].getBiome() == DESERT_BIOME || vertices[index].getBiome() == MED_BIOME)
     {
         if (vertices[index].getResource() != null && vertices[index].getResource().name.Contains("SandHill"))
         {
             return;
         }
         ResourceController resourceCont = (GameObject.FindObjectOfType(typeof(ResourceController)) as ResourceController);
         if (resourceCont != null)
         {
             resourceCont.SandMade(vertices [index]);
         }
         (GameObject.FindObjectOfType(typeof(MusicController)) as MusicController).StartPlacing();
         GameObject sand = Resources.Load("Prefabs/SandHill" + Random.Range(0, 1), typeof(GameObject)) as GameObject;
         sand = Instantiate(sand, transform.TransformPoint(vertices[index].getSphereVector()), Quaternion.identity) as GameObject;
         vertices [index].removeResource();
         vertices [index].setResource(sand);
     }
 }
        public async Task CreateGetReturnsTheCorrectViewModel()
        {
            var campaignSummaryViewModel = new CampaignSummaryViewModel {
                Id = 4, OrganizationId = 1, Name = "TestCampaign"
            };
            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.SendAsync(It.IsAny <CampaignSummaryQuery>())).ReturnsAsync(campaignSummaryViewModel);
            var sut = new ResourceController(mockMediator.Object);

            sut.MakeUserAnOrgAdmin(campaignSummaryViewModel.OrganizationId.ToString());

            var result = await sut.Create(campaignSummaryViewModel.Id) as ViewResult;

            result.Model.ShouldNotBeNull();
            result.Model.ShouldBeOfType <ResourceEditViewModel>();
            var model = result.Model as ResourceEditViewModel;

            model.CampaignId.ShouldBe(campaignSummaryViewModel.Id);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
 /// </summary>
 /// <returns>The computed hash code.</returns>
 /// <exception cref="ObjectDisposedException">The HMAC instance has been disposed.</exception>
 protected override byte[] HashFinal()
 {
     if (m_IsDisposed)
     {
         throw new ObjectDisposedException(this.GetType().FullName, ResourceController.GetString("Error_Disposed"));
     }
     m_HashAlgorithm.TransformFinalBlock(new byte[0], 0, 0);
     byte[] dataHash = m_HashAlgorithm.Hash;
     for (int i = 0; i < 64; i++)
     {
         m_Padded[i] = (byte)(m_KeyBuffer[i] ^ 0x5C);
     }
     m_HashAlgorithm.Initialize();
     m_HashAlgorithm.TransformBlock(m_Padded, 0, m_Padded.Length, m_Padded, 0);
     m_HashAlgorithm.TransformFinalBlock(dataHash, 0, dataHash.Length);
     dataHash = m_HashAlgorithm.Hash;
     Array.Clear(m_KeyBuffer, 0, m_KeyBuffer.Length);
     m_IsHashing = false;
     return(dataHash);
 }
Ejemplo n.º 23
0
        public void CreateResourceType_Failure()
        {
            //Given
            ResourceType resourceType = new ResourceType()
            {
                ResourceTypeName = "VM"
            };
            int tenantId = 1, resourceTypeCreated = 0;

            resourceServiceMoq.Setup(r => r.CreateResourceType(resourceType, tenantId)).Returns(resourceTypeCreated);

            //When
            var controller = new ResourceController(logger.Object, resourceServiceMoq.Object);
            var response   = controller.CreateResourceType(resourceType, tenantId) as BadRequestObjectResult;

            //Then
            Assert.IsType <BadRequestObjectResult>(response);
            Assert.Equal("Resource Type Not created", response.Value);
            resourceServiceMoq.Verify(r => r.CreateResourceType(resourceType, tenantId), Times.Once);
        }
Ejemplo n.º 24
0
        public CmpPage(GameModeController gmCtl)
        {
            m_gmCtl = gmCtl;

            InitializeComponent();

            backgroundImage.Source = ResourceController.GetResourceBitmap("/Image/CmpGM/bg.jpg");
            titleImage.Source      = ResourceController.GetResourceBitmap("/Image/CmpGM/cmp_gmode_title.png");

            m_Game = new CmpGame(this, new CmpButton[]
            {
                cmpButton_0_0, cmpButton_0_1, cmpButton_0_2,
                cmpButton_1_0, cmpButton_1_1, cmpButton_1_2
            });

            m_bPageLoaded = m_bNeedStart = false;

            this.Loaded      += OnPageLoad;
            this.SizeChanged += OnSizeChanged;
        }
Ejemplo n.º 25
0
 public void CoalAtIndex(int index)
 {
     if (getBiomeAtIndex(index) == HIGH_BIOME)
     {
         if (vertices [index].getResource() != null && vertices [index].getResource().name.Contains("Coal"))
         {
             return;
         }
         ResourceController resourceCont = (GameObject.FindObjectOfType(typeof(ResourceController)) as ResourceController);
         if (resourceCont != null)
         {
             resourceCont.CoalMade(vertices [index]);
         }
         (GameObject.FindObjectOfType(typeof(MusicController)) as MusicController).StartPlacing();
         GameObject coal = Resources.Load("Prefabs/CoalVein" + Random.Range(0, 1), typeof(GameObject)) as GameObject;
         coal = Instantiate(coal, transform.TransformPoint(vertices[index].getSphereVector()), Quaternion.identity) as GameObject;
         vertices [index].removeResource();
         vertices [index].setResource(coal);
     }
 }
Ejemplo n.º 26
0
        public void CreateResource_Successfull()
        {
            //Given
            Resource resource = new Resource()
            {
                ResourceName = "Database server"
            };
            int tenantId = 1, resourceCreated = 1;

            resourceServiceMoq.Setup(r => r.CreateResource(resource, tenantId)).Returns(resourceCreated);

            //When
            var controller = new ResourceController(logger.Object, resourceServiceMoq.Object);
            var response   = controller.CreateResource(resource, tenantId) as OkObjectResult;

            //Then
            Assert.IsType <OkObjectResult>(response);
            Assert.Equal("Resource created successfully", response.Value);
            resourceServiceMoq.Verify(r => r.CreateResource(resource, tenantId), Times.Once);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Creates a symmetric <see cref="RC4"/> decryptor object with the specified Key.
 /// </summary>
 /// <param name="rgbKey">The secret key to be used for the symmetric algorithm.</param>
 /// <param name="rgbIV">This parameter is not used an should be set to a null reference, or to an array with zero or one bytes.</param>
 /// <returns>A symmetric ARCFour decryptor object.</returns>
 /// <remarks>This method decrypts an encrypted message created using the <see cref="CreateEncryptor"/> overload with the same signature.</remarks>
 public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[] rgbIV)
 {
     if (m_IsDisposed)
     {
         throw new ObjectDisposedException(this.GetType().FullName);
     }
     if (rgbKey == null)
     {
         throw new ArgumentNullException("rgbKey", ResourceController.GetString("Error_ParamNull"));
     }
     if (rgbKey.Length == 0 || rgbKey.Length > 256)
     {
         throw new CryptographicException(ResourceController.GetString("Error_InvalidKeySize"));
     }
     if (rgbIV != null && rgbIV.Length > 1)
     {
         throw new CryptographicException(ResourceController.GetString("Error_InvalidIVSize"));
     }
     return(new ARCFourManagedTransform(rgbKey));
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Initializes a new Atr instance.
 /// </summary>
 /// <param name="atr">The value of the ATR.</param>
 /// <param name="mask">The mask that corresponds with the ATR.</param>
 /// <exception cref="ArgumentNullException"><i>atr</i> or <i>mask</i> are a null reference.</exception>
 /// <exception cref="ArgumentException"><i>atr</i> or <i>mask</i> have an invalid length.</exception>
 public Atr(byte[] atr, byte[] mask)
 {
     if (atr == null)
     {
         throw new ArgumentNullException("atr", ResourceController.GetString("Error_ParamNull"));
     }
     if (atr.Length == 0)
     {
         throw new ArgumentException(ResourceController.GetString("Error_ParamInvalid"), "atr");
     }
     if (mask == null)
     {
         throw new ArgumentNullException("mask", ResourceController.GetString("Error_ParamNull"));
     }
     if (atr.Length != mask.Length)
     {
         throw new ArgumentException(ResourceController.GetString("Error_ParamInvalid"), "mask");
     }
     Init((byte[])atr.Clone(), (byte[])mask.Clone());
 }
Ejemplo n.º 29
0
    public void Initialize(AnimalData data)
    {
        animalData = data;

        ResourceController resourceController = Resolver.Instance.GetController <ResourceController>();

        Animator anim = GetComponent <Animator>();
        RuntimeAnimatorController  animController     = anim.runtimeAnimatorController;
        AnimatorOverrideController overrideController = new AnimatorOverrideController();

        overrideController.runtimeAnimatorController = animController;
        overrideController["Transform_Placeholder"]  = resourceController.GetAnimation(animalData.transform_animation);
        overrideController["Happy_Placeholder"]      = resourceController.GetAnimation(animalData.happy_animation);
        overrideController["Run_Placeholder"]        = resourceController.GetAnimation(animalData.run_animation);
        anim.runtimeAnimatorController = overrideController;

        anim.SetTrigger("transform");

        Invoke("StartMovement", delayBeforeMovement);
    }
Ejemplo n.º 30
0
 // Update is called once per frame
 void Update()
 {
     if (ownerPlayer != null)
     {
         if (destinationAquired == false)
         {
             Vector3 destination = new Vector3(target.transform.position.x + offsetX, target.transform.position.y + offsetY);
             if (transform.position != destination)
             {
                 transform.position = Vector3.MoveTowards(transform.position, destination, speed);
             }
             else
             {
                 destinationAquired  = true;
                 minionBody.velocity = Vector3.zero;
             }
         }
         else
         {
             if (target == null)
             {
                 Vector3 home = new Vector3(ownerPlayer.transform.position.x, ownerPlayer.transform.position.y);
                 if (transform.position != home)
                 {
                     transform.position = Vector3.MoveTowards(transform.position, home, speed);
                 }
                 else
                 {
                     PlayerController playerController = ownerPlayer.GetComponent <PlayerController>();
                     playerController.minionReturn(minedQuantity);
                     Destroy(gameObject);
                 }
             }
             else
             {
                 ResourceController resourceCtrl = target.GetComponent <ResourceController>();
                 minedQuantity += resourceCtrl.mineResource(miningPower);
             }
         }
     }
 }
Ejemplo n.º 31
0
    public void MouseOverNewObject(GameObject go)
    {
        if (this.curSelectedObject == go)
        {
            return;
        }

        this.curSelectedObject = go;
        Destroy(this.currentObjectInfo);

        if (go.GetComponentInParent <UnitController> () != null)
        {
            UnitController curController = go.GetComponentInParent <UnitController> ();
            this.selectedObjectNameText.text  = curController.UnitData.Name.ToUpper();
            this.selectedObjectNameText.color = Color.white;
            this.currentObjectInfo            = Instantiate(this.selectedUnitPrefab, this.selectedObjectParent.transform) as GameObject;
            this.currentObjectInfo.GetComponent <UnitInfoPanel> ().SetUnitData(curController.UnitData);
            this.currentObjectInfo.transform.position = this.selectedObjectParent.transform.position;
            this.selectedObjectPanel.SetActive(true);
        }
        else if (go.GetComponentInParent <ResourceController> () != null)
        {
            ResourceController curController = go.GetComponentInParent <ResourceController> ();
            this.selectedObjectNameText.text  = curController.Name.ToUpper();
            this.selectedObjectNameText.color = curController.ResColor;
            this.currentObjectInfo            = Instantiate(this.selectedResourcePrefab, this.selectedObjectParent.transform) as GameObject;
            this.currentObjectInfo.GetComponent <ResourceInfoPanel> ().SetResourceData(curController);
            this.currentObjectInfo.transform.position = this.selectedObjectParent.transform.position;
            this.selectedObjectPanel.SetActive(true);
        }
        else if (go.GetComponentInParent <HomeBaseController> () != null)
        {
            HomeBaseController curController = go.GetComponentInParent <HomeBaseController> ();
            this.selectedObjectNameText.text  = "ANCIENT WAGON";
            this.selectedObjectNameText.color = Color.white;
            this.currentObjectInfo            = Instantiate(this.selectedBasePrefab, this.selectedObjectParent.transform) as GameObject;
            this.currentObjectInfo.GetComponent <BaseInfoPanel> ().SetData(curController);
            this.currentObjectInfo.transform.position = this.selectedObjectParent.transform.position;
            this.selectedObjectPanel.SetActive(true);
        }
    }
        public async Task Affirmative(IDialogContext context, LuisResult result)
        {
            if (MeetsMinimumIntentScore(result))
            {
                var orderNumber = StateController.GetConversationData(ConversationState.OrderNumber);

                string message = "";
                if (StateController.GetConversationData(ConversationState.OrderIntent) == OrderIntents.Cancel)
                {
                    bool cancelled = OrderManager.CancelOrder(orderNumber);
                    if (cancelled)
                    {
                        message = String.Format(ResourceController.GetMessage(MessageTitles.CancelSuccessful), orderNumber);
                    }
                    else
                    {
                        message = String.Format(ResourceController.GetMessage(MessageTitles.CancelFailed), orderNumber);
                    }
                }
                else if (StateController.GetConversationData(ConversationState.OrderIntent) == OrderIntents.Return)
                {
                    bool returned = OrderManager.ReturnOrder(orderNumber);
                    if (returned)
                    {
                        message = String.Format(ResourceController.GetMessage(MessageTitles.ReturnSuccessful), orderNumber);
                    }
                    else
                    {
                        message = String.Format(ResourceController.GetMessage(MessageTitles.ReturnFailed), orderNumber);
                    }
                }

                await PostAsyncMethod(context, message);

                context.Wait(MessageReceived);
            }
            else
            {
                await None(context, result);
            }
        }
Ejemplo n.º 33
0
    // Start is called before the first frame update
    void Start()
    {
        p1Resources  = islandA.GetComponentInChildren <ResourceController>();
        p2Resources  = islandB.GetComponentInChildren <ResourceController>();
        p1Production = islandA.GetComponentInChildren <ProductionController>();
        p2Production = islandB.GetComponentInChildren <ProductionController>();

        seaLevel        = GetComponent <SeaLevelController>();
        musicController = GetComponent <MusicController>();

        started = gameOver = false;

        turnActions = new List <Action> [turnLimit];
        for (int i = 0; i < turnLimit; ++i)
        {
            turnActions[i] = new List <Action>();
        }

        // Setup the first turn
        Clicked();
    }
Ejemplo n.º 34
0
        public ModernShellPage()
        {
            this.InitializeComponent();
            if (AppSettings.DrivesManager.ShowUserConsentOnInit)
            {
                AppSettings.DrivesManager.ShowUserConsentOnInit = false;
                DisplayFilesystemConsentDialog();
            }

            var flowDirectionSetting = ResourceContext.GetForCurrentView().QualifierValues["LayoutDirection"];

            if (flowDirectionSetting == "RTL")
            {
                FlowDirection = FlowDirection.RightToLeft;
            }

            App.CurrentInstance = this as IShellPage;
            App.CurrentInstance.NavigationToolbar.PathControlDisplayText = ResourceController.GetTranslation("NewTab");
            App.CurrentInstance.NavigationToolbar.CanGoBack    = false;
            App.CurrentInstance.NavigationToolbar.CanGoForward = false;
        }
Ejemplo n.º 35
0
 // Use this for initialization
 public Unit (Vector2 coord, PlayerManager player, ResourceController jobController) {
     this.player = player;
     this.jobController = jobController;
     moveAgent = new MoveAgent(1.5f, coord, player, this);
 }
Ejemplo n.º 36
0
    protected void LoadResourceSource(int entityId)
    {
        if (entityId < 0)
        {
            return;
        }

        try
        {
            resourceSource = (ResourceController)GameManager.activeInstance.GetGameEntityById(entityId);
        }
        catch
        {
            Debug.Log(string.Format("Failed to load Resource Source"));
        }
    }
Ejemplo n.º 37
0
 public static ResourceController Fixture()
 {
     ResourceController controller = new ResourceController(new ResourceRepository(), "", new LoginView());
     return controller;
 }
Ejemplo n.º 38
0
    private void StartHarvesting(ResourceController resource)
    {
        if (resource == null)
        {
            isHarvesting = false;
            return;
        }

        resourceSource = resource;
        SetWaypoint(resource);
        ResourceType depositType = resource.type;
        if (harvestType != depositType)
        {
            harvestType = depositType;
            currentLoad = 0f;
        }
        isHarvesting = true;
        isDepositing = false;
    }
Ejemplo n.º 39
0
 public void AddStore(ResourceController house)
 {
     Debug.Log("Player get new store registered");
     storeList.Add(house);
 }
Ejemplo n.º 40
0
    /// <summary>
    /// Start this instance.
    /// </summary>
    void Start()
    {
        AndroidJNI.AttachCurrentThread();
        //gpsActivityJavaClass = new AndroidJavaClass ("com.TeamWARIS.WARISProject.CustomGPS");
        _camLoc = gameObject.AddComponent<Geolocation>();
        _camLoc.initGPS();
        _directionx = 0;
        _directiony = 1;
        setCamVecLength(0.00015);
        checkGPS();
        gcs = GetComponent<GUIControllerScript>();
        _location = "";
        _GUIWindow = new Rect(Screen.width / 4 + 10, (Screen.height / 2) + 10, Screen.width / 4 - 20, (Screen.height / 2) - 35);

        rc = (ResourceController)GameObject.Find ("Resource Controller").GetComponent<ResourceController> ();
        buildingManager = rc.GetBuildingManager ();
        staffManager = rc.GetStaffManager ();
        lectureManager = rc.GetLectureManager ();

        gpsActivityJavaClass = new AndroidJavaClass ("com.TeamWARIS.WARISProject.CustomGPS");
    }
Ejemplo n.º 41
0
    public Builder(Vector2 coord, PlayerManager player, ResourceController jobController) : base(coord, player, jobController)
    {

    }