Ejemplo n.º 1
0
 public override bool Handle(OperationRequest operationRequest)
 {
     if (base.Handle(operationRequest))
     {
         AntGrowthDirection direction = (AntGrowthDirection)operationRequest.Parameters[(byte)UpgradeNestParameterCode.Direction];
         Nest nest = peer.Player.Nests[0];
         if (nest.UpgradeNest(direction, peer.Player))
         {
             SendResponse(operationRequest.OperationCode, new Dictionary <byte, object>()
             {
                 { (byte)UpgradeNestResponseParameterCode.CakeCount, peer.Player.CakeCount },
                 { (byte)UpgradeNestResponseParameterCode.Duration, nest.GrowthProperties.duration },
                 { (byte)UpgradeNestResponseParameterCode.Speed, nest.GrowthProperties.speed },
                 { (byte)UpgradeNestResponseParameterCode.Resistant, nest.GrowthProperties.resistant },
                 { (byte)UpgradeNestResponseParameterCode.Population, nest.GrowthProperties.population },
                 { (byte)UpgradeNestResponseParameterCode.Sensitivity, nest.GrowthProperties.sensitivity }
             });
             return(true);
         }
         else
         {
             SendError(operationRequest.OperationCode, StatusCode.InvalidOperation, "無法升級");
             return(false);
         }
     }
     else
     {
         SendError(operationRequest.OperationCode, StatusCode.InvalidParameter, "參數數量錯誤");
         return(false);
     }
 }
Ejemplo n.º 2
0
    public void UpgradeNest(AntGrowthDirection direction)
    {
        var parameter = new Dictionary <byte, object>()
        {
            { (byte)UpgradeNestParameterCode.Direction, direction }
        };

        IANTGame.Service.SendOperation(OperationCode.UpgradeNest, parameter);
    }
Ejemplo n.º 3
0
        public bool UpgradeNest(AntGrowthDirection direction, Player player)
        {
            if (player.UseCake(NestLevelFoodTable.FoodForUpgrade(GrowthProperties.Level)))
            {
                switch (direction)
                {
                case AntGrowthDirection.Duration:
                    growthProperties.duration++;
                    break;

                case AntGrowthDirection.Speed:
                    growthProperties.speed++;
                    break;

                case AntGrowthDirection.Resistant:
                    growthProperties.resistant++;
                    break;

                case AntGrowthDirection.Sensitivity:
                    growthProperties.sensitivity++;
                    break;

                case AntGrowthDirection.Population:
                    growthProperties.population++;
                    break;

                default:
                    return(false);
                }
                OnGrowthPropertiesChange?.Invoke(GrowthProperties);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
    public void UpgradeNest(int directionNumber)
    {
        AntGrowthDirection direction = (AntGrowthDirection)directionNumber;

        IANTGame.ActionManager.OperationManager.UpgradeNest(direction);
    }