示例#1
0
    /// <summary>
    ///
    /// </summary>
    public void ClickOnPlant(string color)
    {
        if (CurrentState.Equals(ActiveItemState.PLANTING))
        {
            Destroy(ActiveItem.gameObject);
        }

        switch (color)
        {
        case "Green":
            ActiveItem = Instantiate(PickAPlant(), GameCanvas).GetComponent <ItemController>();
            ActiveItem.HarvestAmount *= 1;
            ActiveItem.WaterDrain    *= 1;
            break;

        case "Yellow":
            ActiveItem = Instantiate(PickAPlant(), GameCanvas).GetComponent <ItemController>();
            ActiveItem.HarvestAmount *= 1.25f;
            ActiveItem.WaterDrain    *= 1.5f;
            break;

        case "Red":
            ActiveItem = Instantiate(PickAPlant(), GameCanvas).GetComponent <ItemController>();
            ActiveItem.HarvestAmount *= 1.4f;
            ActiveItem.WaterDrain    *= 2.5f;
            break;
        }
        ActiveItem.transform.SetParent(GameObject.FindGameObjectWithTag("Canvas").transform);

        CurrentState = ActiveItemState.PLANTING;
    }
示例#2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(1) && !CurrentState.Equals(ActiveItemState.FREE))
     {
         Destroy(ActiveItem.gameObject);
         CurrentState = ActiveItemState.FREE;
     }
 }
示例#3
0
 /// <summary>
 /// Return to the navigation UI after a planet
 /// </summary>
 public void LaunchFromPlanet()
 {
     rm.IsActive = false;
     LandingUI.SetActive(false);
     NavigationUI.SetActive(true);
     if (!CurrentState.Equals(ActiveItemState.FREE))
     {
         Destroy(ActiveItem.gameObject);
         CurrentState = ActiveItemState.FREE;
     }
 }
示例#4
0
        public void Update()
        {
            if (this.currentCommand == null)
            {
                this.commandQueue.TryDequeue(out this.currentCommand);
            }

            if (this.currentCommand != null)
            {
                if (this.StopFlag)
                {
                    this.Stop();
                }

                this.currentCommand.Update();

                switch (this.currentCommand.State)
                {
                case CommandState.Idel:
                    if (this.currentCommand.Guard())
                    {
                        this.currentCommand.Call();
                    }
                    break;

                case CommandState.Running:
                    break;

                case CommandState.Pause:
                    break;

                case CommandState.Succeed:
                    this.currentCommand.AutoEvent.Set();
                    this.currentCommand.OnFinished?.Invoke();
                    this.currentCommand = null;
                    this.State          = ActiveItemState.Idel;
                    break;

                case CommandState.Failed:
                    this.currentCommand.AutoEvent.Set();
                    this.currentCommand.OnFinished?.Invoke();
                    this.currentCommand = null;
                    this.State          = ActiveItemState.Idel;
                    break;

                default:
                    break;
                }
            }
        }
示例#5
0
 public void Fire(ICommandable command)
 {
     this.State = ActiveItemState.Busy;
     this.commandQueue.Enqueue(command);
 }
示例#6
0
 void Start()
 {
     rm           = GetComponent <ResourceManager>();
     CurrentState = ActiveItemState.FREE;
 }