Exemplo n.º 1
0
    private void AddClickToSelection()
    {
        Vector2    screenPos = BigBookBasic.MousePosition();
        Collider2D col       = Physics2D.OverlapCircle(screenPos, .01f, selectablesMask);

        if (col != null)
        {
            Debug.Log(col.gameObject);

            ChangeSpecificWorldObject(BigBookBasic.GetComponentFromGameObject <WorldObject>(col.gameObject));
        }
    }
Exemplo n.º 2
0
    private void SetTarget(WorldObject worldObject, MovementController[] units, Vector2[] positions)
    {
        switch (worldObject.worldObjectType)
        {
        case ObjectType.Building:
            for (int i = 0; i < units.Length; i++)
            {
                units[i].MoveToWorldObject(worldObject, positions[i], true);
            }
            break;

        case ObjectType.Character:
            for (int i = 0; i < units.Length; i++)
            {
                if (units[i].ac.animator != null)
                {
                    units[i].ac.animator.SetBool("Gathering", false);
                }
                units[i].MoveToWorldObject(worldObject, positions[i], true);
            }
            break;

        case ObjectType.Resource:
        {
            Resource resource = BigBookBasic.GetComponentFromGameObject <Resource>(worldObject.gameObject);
            if (resource != null)
            {
                for (int i = 0; i < units.Length; i++)
                {
                    if (units[i].ac.animator != null)
                    {
                        units[i].ac.animator.SetBool("IsGathering", true);
                        if (resource.available)
                        {
                            units[i].ac.animator.SetBool("IsAttacking", false);
                        }
                        else
                        {
                            units[i].ac.animator.SetBool("IsAttacking", true);
                        }
                    }
                    units[i].MoveToWorldObject(worldObject, positions[i], true, true);
                }
            }
            else
            {
                Debug.Log("geen resource: " + worldObject.worldObjectName);
            }
            break;
        }
        }
    }
Exemplo n.º 3
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(1) && playerSelection.HasWorldoObjectsSelected())
        {
            if (playerSelection.selectedUnits.Count > 0)
            {
                playerSelection.RemoveNullObjectsFromSelection();
                WorldObject[]        selectedObjects = playerSelection.GetSelectedObjects();
                MovementController[] selectedUnits   = new MovementController[selectedObjects.Length];


                if (selectedObjects[0].worldObjectType == ObjectType.Character)
                {
                    for (int i = 0; i < selectedObjects.Length; i++)
                    {
                        selectedUnits[i] = BigBookBasic.GetComponentFromGameObject <MovementController>(selectedObjects[i].gameObject);
                    }
                }

                Vector2      mousePosition = BigBookBasic.MousePosition();
                Collider2D[] colliders     = Physics2D.OverlapCircleAll(mousePosition, .05f);
                Collider2D   col           = BigBookBasic.PickProminentCollider(colliders);
                if (col != null)
                {
                    if (col.gameObject.CompareTag("Ground"))
                    {
                        MoveToPosition(mousePosition, selectedUnits);
                    }
                    else if (col.gameObject.CompareTag("Water"))
                    {
                    }
                    else if (col.gameObject.CompareTag("Resource"))
                    {
                        MoveToObject(col.gameObject, selectedUnits);
                        //ook iets meegeven aan alle betrokken Units zodat ze ook iets gaan doen met die resource
                    }
                    else if (col.gameObject.CompareTag("Character"))
                    {
                        MoveToObject(col.gameObject, selectedUnits);
                    }
                    else if (col.gameObject.CompareTag("Building"))
                    {
                        MoveToObject(col.gameObject, selectedUnits);
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    private void SetupResource()
    {
        Resource resource = BigBookBasic.GetComponentFromGameObject <Resource>(worldObject.gameObject);

        if (resourceImage != null)
        {
            resourceImage.sprite = GUIManager.instance.GetResouceSprite(resource.resourceType);
        }
        if (resourceAmountText != null)
        {
            int am = (int)resource.resourceAmount;
            int ma = (int)resource.maxResourceAmount;
            resourceAmountText.SetText(am.ToString() + "/" + ma.ToString());
        }
        if (resourceBarObject != null)
        {
            resourceBarObject.SetActive(true);
            resourceBar.fillAmount = resource.GetResourcePerunage();
        }
    }
Exemplo n.º 5
0
 public void TooltipObject(GameObject go)
 {
     tooltipPanel.SetActive(true);
     tooltipDisplayShell.Setup(BigBookBasic.GetComponentFromGameObject <WorldObject>(go));
     tooltipPanel.transform.position = TooltipPosition();
 }