Esempio n. 1
0
 public void Travel(RegionBehaviour source, RegionBehaviour destination)
 {
     Source             = source;
     Destination        = destination;
     transform.position = source.gameObject.transform.position;
     Traveling          = true;
 }
Esempio n. 2
0
    public void SendPlane(RegionBehaviour region01, RegionBehaviour region02)
    {
        Plane plane = GetPlaneInstance().GetComponent <Plane>();

        plane.gameObject.SetActive(true);
        plane.Travel(region01, region02);
    }
 public void OnLMBUp()
 {
     if (RegionSelected == this)
     {
         RegionSelected = null;
     }
     RegionSelected = this;
     OnRegionSelectedLMB?.Invoke(this);
 }
    void Update()
    {
        Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit;

        if (hit = Physics2D.Raycast(ray.origin, ray.direction))
        {
            GameObject      go   = hit.collider.gameObject;
            RegionBehaviour regb = go.GetComponent <RegionBehaviour>();
            if (Input.GetMouseButtonUp(0))
            {
                if (go.GetComponent <ToggleGameObject>() != null)
                {
                    go.GetComponent <ToggleGameObject>().ToggleIt();
                }
                else if (regb != null && regb.enabled)
                {
                    regb.OnLMBUp();
                }
                else if (go.GetComponent <InteractIt>() != null)
                {
                    go.GetComponent <InteractIt>().InteractLMB();
                }
            }
            else if (Input.GetMouseButtonUp(1))
            {
                if (regb != null)
                {
                    regb.OnRMBUp();
                }
                else if (go.GetComponent <InteractIt>() != null)
                {
                    go.GetComponent <InteractIt>().InteractRMB();
                }
            }
            else
            {
                if (regb != null && regb.Region.Type != RegionType.Water)
                {
                    RegionBehaviour.RegionLooking = regb;
                }
                else
                {
                    RegionBehaviour.RegionLooking = null;
                }

                if (go.GetComponent <InteractIt>() != null)
                {
                    go.GetComponent <InteractIt>().InteractOver();
                }
            }
        }
    }
 public void Pop(RegionBehaviour region)
 {
     gameObject.transform.SetParent(region.transform, false);
     gameObject.transform.localPosition = Vector3.zero;
     gameObject.transform.localScale    = Vector3.one;
     Able = false;
     //animator.Play("PlagueCase");
     animator.SetBool("Checked", false);
     animator.SetTrigger("Case");
     TimeAt = 0f;
     //Debug.Log("Popped on x: " + region.Region.X + "  y: " + region.Region.Y);
 }
    public void OpenOn(RegionBehaviour regionB)
    {
        float x = regionB.transform.position.x;
        float y = regionB.transform.position.y;

        if (TrumpBehaviour.Trump.IsBuildingWalls)
        {
            return;
        }

        if (lastRegion == regionB)
        {
            lastRegion = null;
            Close();
        }
        else
        {
            lastRegion = regionB;

            RegPopUp pop    = null;
            float    offset = .15f;

            if (x >= 0.0f && y >= 0.0f)
            {
                pop     = RegPopUps.First(z => z.PopUpIdentifier == "UR");
                offset *= -1;
            }
            else if (x >= 0.0f && y < 0.0f)
            {
                pop = RegPopUps.First(z => z.PopUpIdentifier == "DR");
            }
            else if (x < 0.0f && y > 0.0f)
            {
                pop     = RegPopUps.First(z => z.PopUpIdentifier == "UL");
                offset *= -1;
            }
            else
            {
                pop = RegPopUps.First(z => z.PopUpIdentifier == "DL");
            }
            if (pop != null)
            {
                PopUpSprite.sprite = pop.PopUpSprite;
                PopUpSprite.transform.GetChild(0).transform.localPosition = new Vector3(pop.PopUpPivot.x, pop.PopUpPivot.y, 30f);
            }

            PopUpSprite.transform.position = new Vector3(x, y + offset, 10f);
            PopUpSprite.gameObject.SetActive(true);
        }
    }
    void Update()
    {
        if (IsBuildingWalls && RegionBehaviour.RegionLooking != null)
        {
            RegionBehaviour regionBeha = RegionBehaviour.RegionLooking;
            CurrentWall.SetActive(true);
            CurrentWall.transform.position = regionBeha.transform.position;

            if (Input.GetMouseButtonUp(0))
            {
                if (regionBeha.BuildWall(WallPosition))
                {
                    CurrentWall.transform.SetParent(regionBeha.transform);
                    CurrentWall.GetComponent <LiteralWall>().SetRegions(regionBeha.Region, WallPosition);
                    GetNewWall();
                }
                else
                {
                    Debug.Log("Already exist a wall here, Trump... go slowly");
                }
            }
            int val = 0;
            if (Input.GetKeyUp(KeyCode.E))
            {
                val = 1;
            }
            else if (Input.GetKeyUp(KeyCode.Q))
            {
                val = -1;
            }
            WallPosition += val;
            if (WallPosition > 5)
            {
                WallPosition = 0;
            }
            else if (WallPosition < 0)
            {
                WallPosition = 5;
            }
            CurrentWall.transform.rotation = Quaternion.Euler(0, 0, 60 * WallPosition);
        }
        else
        {
            WallPosition = 0;
            CurrentWall.transform.rotation = Quaternion.Euler(0, 0, 120f);
            CurrentWall.SetActive(false);
        }
    }
Esempio n. 8
0
    public void MyStart()
    {
        PopulationButton.onClick.AddListener(() =>
        {
            MapBehaviour.instance.ShowPopulation(showPopulation);
            showPopulation = !showPopulation;
        });

        RegionBehaviour.SubscribeOnClickLMB((region) =>
        {
            if (!region.Region.IsWater())
            {
                PopUp.OpenOn(region);
            }
        });
    }