示例#1
0
    public Transform findHuman(IndieMarc.TopDown.Character botChar)
    {
        List <Human> founded = ContainerEmploy.instance.emptyHumans.OrderBy(h => Vector2.Distance(botChar.transform.position, h.transform.position)).ToList();

        return(founded.First().transform);
    }
示例#2
0
    private void Update()
    {
        if (HouseState == EHouseState.Builded)
        {
            return;
        }

        if (buildProgress >= 100 && HouseState == EHouseState.Destroyed)
        {
            AudioManager.Instance.StopLoopSound("Building");
            AudioManager.Instance.PlaySound("BuildDone");
            progressBuild.gameObject.SetActive(false);
            progressBuild.color      = Color.white;
            progressBuild.fillAmount = 0f;

            iconState.gameObject.SetActive(true);
            iconState.sprite = finishIcon;

            HouseState = EHouseState.Builded;
            ChangeSprite(true);
            smoke.gameObject.SetActive(false);

            if (HouseType == EHouseType.Orange)
            {
                GetComponent <Animator>().enabled = true;
            }

            currentBuilder.buildCount++;
            currentBuilder.score += Coins;

            return;
        }

        if (currentBuilder && HouseState == EHouseState.Destroyed && currentBuilder.getEmployeesCount() >= RequiredWorkers)
        {
            if (buildProgress < 100 && Vector2.Distance(transform.position, currentBuilder.transform.position) < 5)
            {
                AudioManager.Instance.PlayLoopSound("Building");
                progressBuild.gameObject.SetActive(true);
                progressBuild.color = currentBuilder.teamColor;
                iconState.gameObject.SetActive(true);

                smoke.gameObject.SetActive(true);
                buildProgress           += currentBuilder.getEmployeesCount() * Time.deltaTime;
                progressBuild.fillAmount = buildProgress / 100f;
            }
            else
            {
                AudioManager.Instance.StopLoopSound("Building");
                progressBuild.gameObject.SetActive(false);
                progressBuild.color      = Color.white;
                progressBuild.fillAmount = 0f;
                iconState.gameObject.SetActive(false);

                smoke.gameObject.SetActive(false);
                currentBuilder = null;
            }

            // owner = team;

            // HouseState = EHouseState.Building;
            // ChangeSprite();

            // StartCoroutine(BuildingHouse(buildSpeed));
        }
    }
示例#3
0
    public Transform findTarget(IndieMarc.TopDown.Character botChar, Transform lastTarget, out bool humanMode)
    {
        if (player == null)
        {
            player = PlayerMover.Instance.GetComponent <IndieMarc.TopDown.Character>();
        }

        humanMode = false;
        List <Transform> finals    = new List <Transform>();
        Vector2          playerPos = PlayerMover.Instance.transform.position;

        if (botChar.getEmployeesCount() > 15)
        {
            if (botChar.getEmployeesCount() > player.getEmployeesCount())
            {
                finals.Add(PlayerMover.Instance.transform);
            }

            List <House> founded = BuildContainer.Instance.houses.OrderBy(h => Vector2.Distance(playerPos, h.transform.position)).ToList();
            int          len     = founded.Count;
            // len = Mathf.Clamp(len,0,40);
            for (int i = 0; i < len; i++)
            {
                if (!founded[i].isBuilded())
                {
                    finals.Add(founded[i].transform);
                }
            }


            // finals.Clear();
        }

        List <Human> founded2 = ContainerEmploy.instance.emptyHumans.OrderBy(h => Vector2.Distance(playerPos, h.transform.position)).ToList();
        List <Human> founded3 = new List <Human>();

        foreach (Human human in founded2)
        {
            if (!human.used && !human.busy && human.gameObject.activeSelf)
            {
                founded3.Add(human);
            }
        }
        int len2 = founded3.Count;

        len2 = Mathf.Clamp(len2, 0, 40);
        for (int i = 0; i < len2; i++)
        {
            finals.Add(founded3[i].transform);
        }

        finals.Remove(lastTarget);

        if (finals.Count > 0)
        {
            Transform target    = finals[Random.Range(0, finals.Count)];
            Human     testHuman = target.GetComponent <Human>();
            if (testHuman)
            {
                testHuman.busy = true;
                humanMode      = true;
            }

            return(target);
        }

        return(null);
    }
示例#4
0
 // Start is called before the first frame update
 void Start()
 {
     Instance = this;
     player   = GetComponent <IndieMarc.TopDown.Character>();
 }