예제 #1
0
 public override bool OnModeExit()
 {
     hover.Selected(false, m_player);
     hover    = null;
     selected = new ClickAble[0];
     return(true);
 }
예제 #2
0
    // Use this for initialization
    void Awake()
    {
        cameraAudio = Camera.main.GetComponent <AudioSource>();

        GridObject.onBeat = false;
        onBeat            = false;

        beatCounters = new beatObject[timeSig];
        beat         = 0;

        for (int i = 0; i < beatCounters.Length; i++)
        {
            beatCounters[i].go = (GameObject)Instantiate(visualizer, counterAnchor.position + Vector3.right * i * margin + Vector3.back * 2, Quaternion.Euler(180, 0f, 0f));
            beatCounters[i].go.transform.localScale = Vector3.one * scaleMin;
            beatCounters[i].go.name       = "BeatCounter " + i;
            beatCounters[i].mat           = beatCounters[i].go.GetComponent <SpriteRenderer>();
            beatCounters[i].outline       = beatCounters[i].go.transform.GetChild(0).gameObject.GetComponent <SpriteRenderer>();
            beatCounters[i].outline.color = Color.yellow;
        }

        isClickableMap = new Dictionary <GameObject, ClickAble>();
        GameObject[] clickable = GameObject.FindGameObjectsWithTag("Clickable");
        for (int i = 0; i < clickable.Length; i++)
        {
            ClickAble temp = clickable[i].GetComponent <ClickAble>();
            isClickableMap[clickable[i]] = temp;
        }

        sound = GetComponent <AudioSource>();

        timeForBeat = 60 / BPM;
        currentTime = 0;
        clicked     = false;
    }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     isClickableMap = new Dictionary <GameObject, ClickAble>();
     GameObject[] clickable = GameObject.FindGameObjectsWithTag("Clickable");
     for (int i = 0; i < clickable.Length; i++)
     {
         ClickAble temp = clickable[i].GetComponent <ClickAble>();
         isClickableMap[clickable[i]] = temp;
     }
 }
예제 #4
0
 public bool ClearSelection()
 {
     for (int i = 0; i < selected.Length; i++)
     {
         selected[i].Selected(false, m_player);
     }
     selected = new ClickAble[0];
     for (int i = 0; i < currPath.Length; i++)
     {
         currPath[i].Selected(false, m_player);
     }
     if (hover != null)
     {
         hover.Selected(false, m_player);
     }
     hover    = null;
     currPath = new Tile[0];
     return(true);
 }
예제 #5
0
 public override void OnClick(bool[] givenClick)
 {
     if (givenClick[0])
     {
         GameObject cursorObj = FindObjectUnder();
         if (cursorObj != null)
         {
             ClickAble clickItem = cursorObj.GetComponent <ClickAble>();
             if (clickItem != null)
             {
                 if (cursorObj.layer == LayerMask.NameToLayer("Tile"))
                 {
                     Tile clickTile = clickItem as Tile;
                     if (clickTile.GetDomain() != null)
                     {
                         if (m_player.GetCharacter().RulesDomain(clickTile.GetDomain()))
                         {
                             Building[] clickBuilding = clickTile.GetBuildings();
                             if (clickBuilding.Length > 0)
                             {
                                 m_player.ChangeStates(ModeType.build, clickItem);
                             }
                         }
                     }
                     TestMain.MoveCamera(clickTile.GetX(), clickTile.GetY());
                 }
                 if (cursorObj.layer == LayerMask.NameToLayer("UI"))
                 {
                     selected = new ClickAble[] { clickItem };
                     selected[0].Selected(true, m_player);
                 }
                 if (selected.Length > 0)
                 {
                     for (int i = 0; i < selected.Length; i++)
                     {
                         selected[i].Selected(false, m_player);
                     }
                 }
             }
         }
     }
 }
예제 #6
0
    public override void OnHover()
    {
        GameObject cursorObj = FindObjectUnder();

        if (cursorObj != null)
        {
            ClickAble cursorItem = cursorObj.GetComponent <ClickAble>();
            if (cursorItem != null)
            {
                if (cursorObj.layer == LayerMask.NameToLayer("Tile"))
                {
                    if (hover != null)
                    {
                        hover.Hover(false, m_player);
                    }
                    hover = cursorItem;
                    hover.Hover(true, m_player);
                }
            }
        }
    }
예제 #7
0
 public bool ChangeStates(ModeType newMode, ClickAble clickItem = null)
 {
     if (GetCurrentMode().OnModeExit())
     {
         if (clickItem != null)
         {
             if (GetMode(newMode).OnModeEnter(clickItem))
             {
                 m_menu.ChangeMenu((ModeType)currMode, newMode);
                 SetModeType(newMode);
             }
         }
         else
         {
             if (GetMode(newMode).OnModeEnter())
             {
                 m_menu.ChangeMenu((ModeType)currMode, newMode);
                 SetModeType(newMode);
             }
         }
     }
     return(true);
 }
예제 #8
0
 public abstract bool OnModeEnter(ClickAble givenSelected);
예제 #9
0
 public override bool OnModeEnter(ClickAble currentClick)
 {
     TestMain.AddElement <ClickAble>(ref selected, currentClick);
     return(OnModeEnter());
 }
예제 #10
0
    public override void OnHover()
    {
        GameObject cursorObj = FindObjectUnder();

        if (cursorObj != null)
        {
            ClickAble cursorItem = cursorObj.GetComponent <ClickAble>();
            if (cursorItem != null)
            {
                if (cursorObj.layer == LayerMask.NameToLayer("Tile"))
                {
                    if (Building.CanBuildOnTile((Tile)cursorItem, currbuilding, m_player))
                    {
                        if (currbuilding != "Road")
                        {
                            if (hover != null)
                            {
                                hover.Hover(false, m_player);
                            }
                            hover = cursorItem;
                            cursorItem.Hover(true, m_player);
                        }
                        else
                        {
                            if (selected.Length > 0)
                            {
                                try
                                {
                                    Tile[] tempPath = TestMain.GetMap().GetBestPath((Tile)selected[selected.Length - 1], (Tile)cursorItem, PathType.CompareTerrain);
                                    if (currPath != null)
                                    {
                                        for (int i = 0; i < currPath.Length; i++)
                                        {
                                            currPath[i].Selected(false, m_player);
                                        }
                                    }
                                    currPath = tempPath;
                                    for (int i = 0; i < currPath.Length; i++)
                                    {
                                        currPath[i].Hover(true, m_player);
                                    }
                                    for (int i = 0; i < selected.Length; i++)
                                    {
                                        selected[i].Selected(true, m_player);
                                    }
                                }
                                catch (NoPathException e)
                                {
                                    //hit ocean or imppassible
                                }
                            }
                            else
                            {
                                if (hover != null)
                                {
                                    hover.Selected(false, m_player);
                                }
                                if (Building.CanBuildOnTile((Tile)cursorItem, currbuilding, m_player))
                                {
                                    hover = cursorItem;
                                    hover.Selected(true, m_player);
                                }
                            }
                        }
                    }
                }
            }
            clickLength++;
        }
    }
예제 #11
0
 public override void OnClick(bool[] givenClick)
 {
     if (hover != null)
     {
         hover.Selected(false, m_player);
     }
     hover = null;
     if (givenClick[0])
     {
         if (clickLength > 15)
         {
             GameObject cursorObj = FindObjectUnder();
             if (cursorObj != null)
             {
                 hover = null;
                 ClickAble clickItem = cursorObj.GetComponent <ClickAble>();
                 if (clickItem != null)
                 {
                     if (cursorObj.layer == LayerMask.NameToLayer("Tile"))
                     {
                         if (Building.CanBuildOnTile((Tile)clickItem, currbuilding, m_player))
                         {
                             if (currbuilding != "Road")
                             {
                                 m_player.AddBuilding((Tile)clickItem, currbuilding);
                                 selected = new ClickAble[0];
                             }
                             else
                             {
                                 if (selected.Length == 0)
                                 {
                                     TestMain.AddElement <ClickAble>(ref selected, clickItem);
                                     selected[0].Selected(true, m_player);
                                 }
                                 else
                                 {
                                     TestMain.AddElement <ClickAble>(ref selected, (ClickAble[])currPath);
                                     if (givenClick[0])
                                     {
                                         for (int i = 0; i < selected.Length; i++)
                                         {
                                             m_player.AddBuilding((Tile)selected[i], currbuilding);
                                             selected[i].Selected(false, m_player);
                                         }
                                         selected = new ClickAble[0];
                                     }
                                 }
                             }
                         }
                     }
                     if (cursorObj.layer == LayerMask.NameToLayer("UI"))
                     {
                         selected = new ClickAble[] { clickItem };
                         selected[0].Selected(true, m_player);
                     }
                     clickLength = 0;
                 }
             }
         }
     }
     else if (givenClick[1])
     {
         if (selected.Length < 1)
         {
             m_player.ChangeStates(ModeType.observe);
         }
         else
         {
             ClearSelection();
         }
     }
 }
예제 #12
0
 public override bool OnModeEnter(ClickAble givenSelected)
 {
     throw new NotImplementedException();
 }