Пример #1
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown("1")) {
            Collapse();
            }
            if (Input.GetKeyDown("2")) {
            Expand();
            }

            // "Collision" Detection for Cards
            if (mouseOverList.Count > 0) {
            lastCardToDraw = mouseOverList[0];

            if (Input.GetMouseButtonUp(0)) {
                if (lastCardToDraw != cardList[0]) {
                    SetCard(lastCardToDraw);
                }
            }
            // Clear "Collisions"
            mouseOverList.Clear();
            } else {
            lastCardToDraw = null;
            }
        }
Пример #2
0
 public int SortByName(Card x, Card y)
 {
     return x.name.CompareTo(y.name);
 }
Пример #3
0
        public void DrawCard(Card card)
        {
            Color color = Color.clear;
            if (selected != null) {
            if (card.name == selected) {
                color = Color.blue;  //.yellow;
            } else if (card.species.preyList.ContainsValue (selected)) {
                color = Color.red;
            } else if (card.species.predatorList.ContainsValue (selected)) {
                color = Color.green;
            }
            }

            if (color == Color.clear || card.name == selected) {
            card.color = Color.black;
            } else {
            card.color = color;
            }

            //jtc - override with info from manager
            string name = manager.MatchSeriesLabel (card.name);
            if (name != null) {
            color = manager.seriesColors [name];
            card.color = color;

            }
            card.Draw ();

            // Selection
            if (color != Color.clear) {
            Functions.DrawBackground (card.GetRect (), cardHighlightFullTexture, color);

            if (card.name == selected && card.species.preyList.ContainsValue (selected)) { // Prey = Self
                Functions.DrawBackground (new Rect (card.x + 5, card.y + 5, card.width - 10, card.height - 10),
                                          cardHighlightFullTexture,
                                          Color.green
                );
            }
            }

            if (card.GetRect ().Contains (Event.current.mousePosition)) {
            mouseOverList.Add (card.name);

            Functions.DrawBackground (card.GetRect (), cardHighlightTexture, Color.yellow);
            }

            if (GUI.Button (card.GetRect (), "", GUIStyle.none)) {
            if (card.name == selected) {
                selected = null;
            } else {
                selected = card.name;
            }
            }
        }
Пример #4
0
        public void SetCard(Card card)
        {
            if (cardList.Count > 0 && card != cardList[0]) {
            predatorList.Clear();
            preyList.Clear();
            }

            if (cardList.Contains(card)) {
            int index = cardList.IndexOf(card);
            cardList.RemoveRange(0, index);
            } else {
            if (cardList.Count > 5) {
                cardList.RemoveAt(cardList.Count - 2);
            }

            cardList.Insert(0, card);
            }

            card.x = (width - card.width) / 2;
            card.y = (height - card.height) / 2;

            for (int i = cardList.Count - 1; i >= 0; i--) {
            float y = (height - card.height) / 2 - i * card.height * 0.15f;

            if (cardList.Count > 1 && i == cardList.Count - 1) {
                y -= card.height * 0.15f;
            }

            cardList[i].Translate(cardList[i].x, y, 1.2f);
            }

            List<Card> tempList = new List<Card>();
            GameState gs = GameObject.Find ("Global Object").GetComponent<GameState> ();

            foreach (int species_id in card.species.predatorList.Keys) {
            SpeciesData species = SpeciesTable.speciesList[species_id];
            //for converge game, ignore predators not currently in ecosystem
            if (mode == Constants.MODE_CONVERGE_GAME && !gs.speciesList.ContainsKey(species_id)) {
                continue;
            }

            string name = manager.MatchSeriesLabel (species.name);
            Texture2D image = Resources.Load<Texture2D>(Constants.IMAGE_RESOURCES_PATH + species.name);
            Card temp = new Card(
                species.name,
                image,
                species,
                new Rect(card.x, card.y, 160, 200),
                name == null ? Color.red : manager.seriesColors [name]
                );

            tempList.Add(temp);
            }

            tempList.Sort(SortByName);
            CreateLayout(tempList, predatorList, -1);

            tempList = new List<Card>();

            foreach (int species_id in card.species.preyList.Keys) {
            SpeciesData species = SpeciesTable.speciesList[species_id];
            //for converge game, ignore prey not currently in ecosystem
            if (mode == Constants.MODE_CONVERGE_GAME && !gs.speciesList.ContainsKey(species_id)) {
                continue;
            }

            string name = manager.MatchSeriesLabel (species.name);
            Texture2D image = Resources.Load<Texture2D>(Constants.IMAGE_RESOURCES_PATH + species.name);
            Card temp = new Card(
                species.name,
                image,
                species,
                new Rect(card.x, card.y, 160, 200),
                name == null ? Color.green : manager.seriesColors [name]
                );

            tempList.Add(temp);
            }

            tempList.Sort(SortByName);
            CreateLayout(tempList, preyList, 1);

            Expand();
        }
Пример #5
0
        public void Refresh()
        {
            foreach (SpeciesData species in speciesTable.Values) {
            Texture2D image = Resources.Load (Constants.IMAGE_RESOURCES_PATH + species.name) as Texture2D;

            Card card = new Card (species.name, image, species, new Rect (0, 0, 160, 200));
            cardList [species.name] = card;
            }

            //		List<string> contents = new List<string>();
            //		GameState gs = GameObject.Find("Global Object").GetComponent<GameState>();
            //
            //		foreach (Species species in gs.speciesList.Values) {
            //			contents.Add(species.name);
            //		}
            //
            //		ecoList.Clear();
            //		contents.Sort(SortByTrophicLevels);
            //		Prepare(contents, ecoList);

            shopList.Clear ();
            List<string> tempList = new List<string> (cardList.Keys);
            tempList.Sort (SortByTrophicLevels);
            Prepare (tempList, shopList);
        }