Наследование: MonoBehaviour
Пример #1
0
    void Chop(GameObject target_tree)
    {
        TreeController treeScript = target_tree.GetComponent <TreeController>();

        treeScript.take_damage(5);
        Destroy(gameObject);
    }
Пример #2
0
 /// <summary>
 /// Primary constructor.
 /// </summary>
 /// <param name="persistence">
 /// The entity persistence.
 /// </param>
 /// <param name="tree">
 /// The tree controller.
 /// </param>
 /// <param name="helper">
 /// The folder helper.
 /// </param>
 public FormHelper(IEntityPersistence persistence, TreeController tree, FolderHelper helper, ILocalizationHelper localizationHelper)
 {
     Persistence        = persistence;
     Tree               = tree;
     Helper             = helper;
     LocalizationHelper = localizationHelper;
 }
Пример #3
0
    public void ShowFruitHintTwo()
    {
        Debug.Log("ShowFruitHintTwo");

        int treeIndex = GetTreeIndexOfColor(colourID);

        if (treeIndex > placedTrees.Length || treeIndex < 0)
        {
            return;
        }

        if (currentHighlightedTree != null)
        {
            currentHighlightedTree = placedTrees[treeIndex].GetComponent <TreeController>();
        }

        if (currentHighlightedTree != null)
        {
            Vector3 offset = new Vector3(3.0f, 3.0f, 0.0f);

            if (treeIndex == 1 || treeIndex == 2)
            {
                transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
                offset = new Vector3(-offset.x, offset.y, offset.z);
            }
            else
            {
                transform.localScale = Vector3.one;
            }

            ShowPointFinger(currentHighlightedTree.TreeTop.position, offset);
            StartMovingHandToBasket(HintHand, BasketController.gameObject);
        }
    }
    private void OnTriggerEnter2D(Collider2D col)
    {
        // Tree
        if (col.gameObject.tag == "Flower")
        {
            TreeController tree = col.gameObject.GetComponent <TreeController>();
            if (this.tankScript.HasWater(tree.GetLevelCost()) && tree.CanLevelUp())
            {
                this.tankScript.UseWater(tree.GetLevelCost());
                tree.LevelUp();
            }
        }

        // Water
        if (col.gameObject.tag == "Water")
        {
            WaterSource source = col.gameObject.GetComponent <WaterSource>();
            int         empty  = this.tankScript.GetWaterCapacity() - this.tankScript.GetWaterAmount();
            this.tankScript.AddWater(source.GetWater(empty));
            if (empty > 0)
            {
                this.audio.clip = this.splash;
                this.audio.Play();
            }
        }
    }
Пример #5
0
 private void onTreeControllerLoadingContent(TreeController treeController)
 {
     if (TreeController.Equals(treeController) && !loadingController.HasLoadingSystem(this))
     {
         loadingController.AddLoadingSystem(this);
     }
 }
Пример #6
0
 private void onTreeControllerContentLoaded(TreeController treeController)
 {
     if (TreeController.Equals(treeController) && loadingController.HasLoadingSystem(this))
     {
         loadingController.RemoveLoadingSystem(this);
     }
 }
Пример #7
0
 protected override void Initialize()
 {
     base.Initialize();
     controller = new TreeController {
         Handler = this
     };
     Control.Background = sw.SystemColors.WindowBrush;
     Control.KeyDown   += (sender, e) =>
     {
         if (e.Key == sw.Input.Key.Enter)
         {
             if (SelectedItem != null)
             {
                 Callback.OnActivated(Widget, new TreeGridViewItemEventArgs(SelectedItem));
             }
         }
     };
     Control.MouseDoubleClick += delegate
     {
         if (SelectedItem != null)
         {
             Callback.OnActivated(Widget, new TreeGridViewItemEventArgs(SelectedItem));
         }
     };
 }
    // Start is called before the first frame update
    void Start()
    {
        worldSettings = FindObjectOfType <WorldSettings>();
        controller    = GetComponent <CharacterController>();
        worldSettings = FindObjectOfType <WorldSettings>();
        anim          = GetComponent <Animator>();

        raycast = GetComponent <RaycastController>();
        if (raycast != null)
        {
            int inventoryLayerMask = 1 << LayerMask.NameToLayer("Enemy");
            raycast.AddLayerMask(inventoryLayerMask);
        }

        equipper         = GetComponent <ItemEquipper>();
        attack           = GetComponent <PlayerAttack>();
        treeController   = GetComponent <TreeController>();
        cameraAdjuster   = GetComponent <CameraAdjuster>();
        playerStatistics = GetComponent <PlayerStatistics>();
        itemCollector    = GetComponent <ItemCollector>();

        totalSwingTime = GetSwimgTimeByAnimator(anim);

        reticleMissColor = reticle.color;
    }
Пример #9
0
 public TreeGridViewHandler()
 {
     controller = new TreeController {
         Handler = this
     };
     controller.CollectionChanged += HandleCollectionChanged;
 }
Пример #10
0
        public async void TestTreeIndex(string request)
        {
            var controller = new TreeController();
            var result     = (await controller.Get(request)).Value;

            Assert.True(BalanceExample.IsAvl(result));
        }
Пример #11
0
 public TreeGridViewHandler()
 {
     controller = new TreeController {
         Handler = this
     };
     controller.CollectionChanged += (sender, e) => UpdateCollection();
 }
Пример #12
0
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     Instance = this;
 }
Пример #13
0
 protected override void Initialize()
 {
     base.Initialize();
     controller = new TreeController {
         Handler = this
     };
     Control.Background = sw.SystemColors.WindowBrush;
 }
Пример #14
0
    // Use this for initialization

    void Start()
    {
        GameObject     mainHill = buildHill();
        TreeController tc       = new TreeController(treefab);

        tc.Environment = this.transform;
        tc.populateTreesOnObject(mainHill, 1);
    }
Пример #15
0
 protected override void Initialize()
 {
     base.Initialize();
     controller = new TreeController {
         Handler = this
     };
     Control.SetResourceReference(swc.Panel.BackgroundProperty, sw.SystemColors.WindowBrushKey);
     Control.PreviewKeyDown += Control_PreviewKeyDown;
 }
Пример #16
0
		public static FrameworkElement Create (FrameworkElement content, TreeController controller)
		{
			var panel = new StackPanel { Orientation = Orientation.Horizontal };
			var button = new TreeToggleButton { Controller = controller, Width = 16 };
			panel.Children.Add (button);
			panel.DataContextChanged += (sender, e) => button.Configure(panel.DataContext as ITreeGridItem);
			panel.Children.Add (content);
			return panel;
		}
 // Update is called once per frame
 void Update()
 {
     if (die)
     {
         return;
     }
     if (PlayerDetector.CollisionObjects.Count > 0)
     {
         target        = PlayerDetector.CollisionObjects[0].gameObject;
         beingChased   = true;
         agent.enabled = true;
         animator.SetBool("FrontTree", false);
         if (targetTree != null)
         {
             targetTree.TrollList.Remove(this);
             targetTree = null;
         }
     }
     if (!beingChased)
     {
         if (CloseTreeDetector.CollisionObjects.Count > 0 && targetTree == null)
         {
             target = CloseTreeDetector.CollisionObjects[0].gameObject;
             animator.SetBool("FrontTree", true);
             this.transform.LookAt(target.transform.position);
             agent.enabled = false;
             targetTree    = target.GetComponent <TreeController>();
             targetTree.TrollList.Add(this);
         }
         else if (TreeDetector.CollisionObjects.Count > 0 && target == null)
         {
             target        = TreeDetector.CollisionObjects[Random.Range(0, TreeDetector.CollisionObjects.Count)].gameObject;
             agent.enabled = true;
         }
         else if (target != null)
         {
             Run();
         }
         else
         {
             WalkAround();
         }
     }
     else
     {
         if (Vector3.Distance(target.transform.position, this.transform.position) > feelOK)
         {
             beingChased = false;
             target      = null;
         }
         else
         {
             Flee();
         }
     }
 }
Пример #18
0
    void Start()
    {
        treeController = TreeController.singleton;
        button         = GetComponent <Button>();
        button.onClick.AddListener(Upgrade);
        string parentName      = transform.parent.name;
        char   parentIndexCode = parentName[parentName.Length - 1];

        index = ((int)parentIndexCode - '0') - 1;
    }
        public void WhenAddLeafCommandAndRepoDoesNotContainSpecifiedTree_ExpectException()
        {
            var value          = 321;
            var treeController = new TreeController(_treeRepo.Object, _treeFactory.Object);

            treeController.AddLeaf(new AddLeafCommand()
            {
                Value = value, TreeId = It.IsAny <Guid>()
            });
        }
        public void WhenPlantTreeCommand_ExpectFactoryPlantTreeCalled()
        {
            var value          = 123;
            var treeController = new TreeController(_treeRepo.Object, _treeFactory.Object);

            treeController.PlantTree(new PlantTreeCommand()
            {
                Value = value
            });;
            _treeFactory.Verify(x => x.PlantTree(value));
        }
Пример #21
0
 private void createControllers(ILifetimeScope scope)
 {
     _configController        = scope.Resolve <ConfigController>();
     _exportController        = scope.Resolve <GUIExportController>();
     _animationController     = scope.Resolve <AnimationController>();
     _treeController          = scope.Resolve <TreeController>();
     _vramController          = scope.Resolve <VRAMController>();
     _cameraController        = scope.Resolve <CameraController>();
     _fileOpenController      = scope.Resolve <FileOpenController>();
     _updateCheckerController = scope.Resolve <UpdateCheckerController>();
 }
Пример #22
0
        public TreeTogglePanel(FrameworkElement content, TreeController controller)
        {
            Background = swm.Brushes.Transparent;             // needed?
            button     = new TreeToggleButton {
                Controller = controller, Width = 16
            };
            SetDock(button, Dock.Left);
            Children.Add(button);
            Children.Add(content);
            _content = content;

            DataContextChanged += OnDataContextChanged;
        }
        public void WhenPlantTreeCommand_ExpectRepositoryInsertCalled()
        {
            var value          = 123;
            var tree           = new Tree();
            var treeController = new TreeController(_treeRepo.Object, _treeFactory.Object);

            _treeFactory.Setup(x => x.PlantTree(value)).Returns(tree);
            treeController.PlantTree(new PlantTreeCommand()
            {
                Value = value
            });;
            _treeRepo.Verify(x => x.Insert(tree));
        }
Пример #24
0
    private void Awake()
    {
        gm = GameManager.instance;
        hc = GetComponent <HealthController>();

        tree = GetComponent <TreeController>();
        if (tree)
        {
            tree.fs = this;
        }

        gm.foodSources.Add(this);
    }
Пример #25
0
    private void Start()
    {
        TreeController = transform.GetComponentInParent <TreeController>();
        TreeController.CheckNewBranch(transform.position);

        transform.localScale = Vector3.zero;

        float maxScale    = TreeController.subBranchScaleModificator;
        float growthSpeed = TreeController.branchGrowthSpeed;
        float growthDelay = generation < 3 ? 0f : Random.Range(0f, TreeController.maxGrowthDelay);

        StartCoroutine(Grow(maxScale, growthSpeed, growthDelay));
    }
Пример #26
0
        public static FrameworkElement Create(FrameworkElement content, TreeController controller)
        {
            var dock   = new DockPanel();
            var button = new TreeToggleButton {
                Controller = controller, Width = 16
            };

            DockPanel.SetDock(button, Dock.Left);
            dock.Children.Add(button);
            dock.DataContextChanged += (sender, e) => button.Configure(dock.DataContext as ITreeGridItem);
            dock.Children.Add(content);
            return(dock);
        }
    private void Update()
    {
        fireTimer += Time.deltaTime;
        timer     += Time.deltaTime;
        if (fireCount > treesNeededToLose)
        {
            print("Game over! You lose!");
            SceneManager.LoadScene("GameOver");
            return;
        }
        if (timer > gameInterval)
        {
            print("Congratulations! You score is: " + (8 - fireCount));

            // Add to the GameController score
            print(8 - fireCount);
            int currentTime = Mathf.RoundToInt(8 - fireCount);
            GC.addScore(currentTime);

            // SceneManager.LoadScene(1);
            // Change the random number to something else
            // 2,3,5,6
            // This is scene 4
            int sceneNum;
            do
            {
                sceneNum = Random.Range(2, 7);
            } while (sceneNum == 4);

            SceneManager.LoadScene(sceneNum);

            return;
        }
        if (fireTimer < fireTimeInterval)
        {
            return;
        }
        fireTimer = 0;
        System.Random  randNum    = new System.Random();
        int            num1       = randNum.Next(0, 7);
        GameObject     treeObject = GameObject.Find("Tree" + num1);
        TreeController tcontrol   = treeObject.GetComponent(typeof(TreeController)) as TreeController;

        if (tcontrol.onFire)
        {
            return;
        }
        tcontrol.onFire = true;
        fireCount++;
    }
        public void WhenAddLeafCommand_ExpectAddLeafCalledOnTree()
        {
            var value = 321;
            var tree  = new Mock <ITree>();

            _treeRepo.Setup(x => x.GetById(It.IsAny <Guid>())).Returns(tree.Object);
            var treeController = new TreeController(_treeRepo.Object, _treeFactory.Object);

            treeController.AddLeaf(new AddLeafCommand()
            {
                Value = value, TreeId = It.IsAny <Guid>()
            });
            tree.Verify(x => x.AddLeaf(value));
        }
Пример #29
0
        public static FrameworkElement Create(FrameworkElement content, TreeController controller)
        {
            var panel = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            var button = new TreeToggleButton {
                Controller = controller, Width = 16
            };

            panel.Children.Add(button);
            panel.DataContextChanged += (sender, e) => button.Configure(panel.DataContext as ITreeGridItem);
            panel.Children.Add(content);
            return(panel);
        }
Пример #30
0
 private void Swing(Collider2D col)
 {
     if (col.tag == "Tree")
     {
         TreeController cTree = col.gameObject.GetComponent <TreeController>();
         cTree.DamageTree(swingDmg);
         Debug.Log("Tree hit for " + swingDmg);
     }
     else if (col.tag == "Bush")
     {
         BushController cBush = col.gameObject.GetComponent <BushController>();
         cBush.DamageBush(swingDmg);
     }
 }
Пример #31
0
    IEnumerator UpdateCoroutine(int treeIndex)
    {
        while (true)
        {
            tree = TreesController.instance.trees[treeIndex];
            UpdatePopup();
            yield return(new WaitForEndOfFrame());

            if (Input.GetKey(KeyCode.Escape))
            {
                Close();
            }
        }
    }
Пример #32
0
 void Start()
 {
     _controller = HelloApp.App.Get<TreeController>();
     var model = _controller.SceneInfo().Model.As<SceneInfoViewModel>();
     _cam = model.Camera;
     _controller.Reset();
     SetupButtons(model);
     DrawGround();
     DrawHelp(true);
     _controller.SetPaused(false);
 }
Пример #33
0
    void Awake()
    {
        if (controller == null)
        {
            DontDestroyOnLoad(gameObject);
            controller = this;
        }
        else if (controller != this)
        {
            Destroy(gameObject);
        }
        refineryController = GetComponentInChildren<RefineryController>();
        treeController = GetComponentInChildren<TreeController>();

        //rawSap = new List<GameObject>();
        rawSapGameObject = Resources.Load("Prefabs/RawSap", typeof(GameObject)) as GameObject;
    }
Пример #34
0
 // Use this for initialization
 void Start()
 {
     tree = GameObject.Find("Tree").GetComponentInChildren<TreeController>();
 }
Пример #35
0
	// Use this for initialization
	void Start () {
        animator = GetComponent<Animator>();
        treeController = FindObjectOfType<TreeController>();
        scoreController = FindObjectOfType<ScoreController>();
        timeController = FindObjectOfType<TimeController>();
	}