public override int GetHashCode()
        {
            int hash = 1;

            if (OwnProject.Length != 0)
            {
                hash ^= OwnProject.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Id != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (IsBack != false)
            {
                hash ^= IsBack.GetHashCode();
            }
            if (PrefabPath.Length != 0)
            {
                hash ^= PrefabPath.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
示例#2
0
        private void Update()
        {
            if (IsStarted)
            {
                float time = Time.deltaTime;
                TimeTheUnitWent += time;
                Timer           -= time;

                if (Timer <= 0)
                {
                    Timer        = 0;
                    IsOnResource = true;
                    IsStarted    = false;
                    Timer        = UnitGather.Resource.GetTime();
                    Counter      = 0;
                }
                UpdateText();
            }

            if (IsOnResource)
            {
                float reduceTime = Time.deltaTime;
                Timer   -= reduceTime;
                Counter += reduceTime;
                bool isEmpty = false;

                if (Counter >= UnitGather.Resource.GetTimeToEarnResourcesInSeconds)
                {
                    Counter -= UnitGather.Resource.GetTimeToEarnResourcesInSeconds;
                    if (UnitGather.Resource.GetWoodAmount > 0)
                    {
                        int amount = UnitGather.Resource.GetResource(EResource.Wood, 1);
                        UnitGather.AddResource(EResource.Wood, amount);
                    }
                    else if (UnitGather.Resource.GetStoneAmount > 0)
                    {
                        int amount = UnitGather.Resource.GetResource(EResource.Stone, 1);
                        UnitGather.AddResource(EResource.Stone, amount);
                    }
                    else if (UnitGather.Resource.GetSteelAmount > 0)
                    {
                        int amount = UnitGather.Resource.GetResource(EResource.Steel, 1);
                        UnitGather.AddResource(EResource.Steel, amount);
                    }
                    else if (UnitGather.Resource.GetFoodAmount > 0)
                    {
                        int amount = UnitGather.Resource.GetResource(EResource.Food, 1);
                        UnitGather.AddResource(EResource.Food, amount);
                    }
                    else if (UnitGather.Resource.GetToilettePaperAmount > 0)
                    {
                        int amount = UnitGather.Resource.GetResource(EResource.Toilette, 1);
                        UnitGather.AddResource(EResource.Toilette, amount);
                    }
                    else
                    {
                        isEmpty = true;
                    }
                }


                if (isEmpty)
                {
                    OnButton_Return();
                }


                UpdateText();
            }

            if (IsReturning)
            {
                float reduceTime = Time.deltaTime;
                Timer -= reduceTime;
                if (Timer <= 0)
                {
                    IsBack?.Invoke(UnitGather.Unit);
                }
                UpdateText();
            }
        }