Exemple #1
0
    private void SetDestinationSystem(int targetSystem, string task)
    {
        float offence   = 0f;
        int   hero      = -1;
        bool  foundHero = false;

        for (int k = 0; k < player.playerOwnedHeroes.Count; ++k)
        {
            heroScript = player.playerOwnedHeroes[k].GetComponent <HeroScriptParent>();

            if (offence < heroScript.assaultDamage && heroScript.isBusy == false)
            {
                offence   = heroScript.assaultDamage;
                hero      = k;
                foundHero = true;
            }
        }

        if (foundHero == true)
        {
            HeroMovement heroMovement = player.playerOwnedHeroes[hero].GetComponent <HeroMovement>();
            heroScript = player.playerOwnedHeroes[hero].GetComponent <HeroScriptParent>();

            heroMovement.FindPath(heroScript.heroLocation, MasterScript.systemListConstructor.systemList[targetSystem].systemObject, true);

            heroScript.isBusy = true;

            if (task == "Invade")
            {
                heroScript.aiInvadeTarget = targetSystem;
            }
        }
    }
Exemple #2
0
    void Update()
    {
        hit           = new RaycastHit();
        currentTarget = null;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            if (Input.GetMouseButtonDown(0))            //Used to start double click events and to identify systems when clicked on. Throws up error if click on a connector object.
            {
                if (hit.collider.gameObject.tag == "Hero")
                {
                    currentHero = hit.collider.gameObject;
                    heroScript  = currentHero.GetComponent <HeroScriptParent>();

                    if (heroScript.heroOwnedBy != MasterScript.playerTurnScript.playerRace)
                    {
                        currentHero = null;
                    }
                }
            }

            if (hit.collider.gameObject.tag == "StarSystem")
            {
                if (currentHero != null)
                {
                    currentTarget = hit.collider.gameObject;
                    heroMovement  = currentHero.GetComponent <HeroMovement> ();

                    if (heroMovement.allowMovement == false)
                    {
                        heroMovement.FindPath(heroScript.heroLocation, hit.collider.gameObject, false);

                        if (Input.GetMouseButtonDown(1))
                        {
                            heroMovement.allowMovement = true;

                            if (heroScript.invasionObject != null)
                            {
                                Destroy(heroScript.invasionObject);
                            }
                        }

                        DestroyUIPath();

                        for (int i = 0; i < heroMovement.finalPath.Count - 1; ++i)
                        {
                            pathToSystem.Add(MasterScript.uiObjects.CreateConnectionLine(heroMovement.finalPath[i], heroMovement.finalPath[i + 1]));
                        }
                    }
                }
            }

            if (hit.collider.gameObject.tag != "StarSystem")
            {
                DestroyUIPath();
            }
        }

        if (currentTarget == null)
        {
            DestroyUIPath();
        }

        ShowHeroDetails();
    }