Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        CharacterSpriteManager man = GameObject.Find("Player").GetComponent <CharacterSpriteManager>();
        int j = 1;

        for (int i = 0; i < GameManager.instance.players.Count; i++)
        {
            Player p = GameManager.instance.players[i];
            if (p.team == GameManager.instance.winningTeam)
            {
                GameObject.Find("WinningPlayer" + j).GetComponent <SpriteRenderer>().sprite =
                    man.SpritesForCharacter(p.character).winning;
                j++;
            }
        }

        switch (GameManager.instance.winningTeam)
        {
        case 0:
            GameObject.Find("WinText").GetComponent <SpriteRenderer>().sprite = wintext1;
            break;

        case 1:
            GameObject.Find("WinText").GetComponent <SpriteRenderer>().sprite = wintext2;
            break;
        }
    }
    // ------------------------------
    // Abstract class implementation
    // ------------------------------

    protected override void DoFragment(Fragment fragment)
    {
        frg             = fragment;
        msg             = frg.Msg;
        nameText.text   = frg.Name;
        charactersShown = 0;
        UpdateText();
        scroll.value  = 1;
        state         = State.Opening;
        managingGroup = dialogGroup;
        managingGroup.gameObject.SetActive(true);
        interactionBlocker.SetActive(true);

        if (frg.Msg == "")
        {
            state = State.Closing;
        }

        if (frg.Character != "")
        {
            faceCamera.character = GameObject.Find(frg.Character);

            if (faceCamera.character)
            {
                currentCharacter = faceCamera.character.GetComponent <CharacterSpriteManager>();
                if (frg.Parameter != "")
                {
                    currentCharacter.ChangeSprite(frg.Parameter);
                }

                face.uvRect = faceCamera.character.transform.localScale.x >= 0 ? new Rect(1, 0, -1, 1) : new Rect(0, 0, 1, 1);
            }
            else
            {
                Debug.LogWarning("Personaje no encontrado: " + frg.Character);
            }
        }

        fondoTexto.sprite = frg.Parameter == "narrativo" ? texturaPensamiento : texturaNormal;
        textHolder.color  = frg.Parameter == "narrativo" ? colorTextoPensamiento : colorTextoNormal;

        var size = face.rectTransform.sizeDelta;

        size.x = faceCamera.character ? size.y : 0;
        face.rectTransform.sizeDelta = size;

        viewPort.anchoredPosition = new Vector2(faceCamera.character ? startingViewportX : face.rectTransform.anchoredPosition.x, viewPort.anchoredPosition.y);
    }
Exemplo n.º 3
0
    private void Awake()
    {
        if (_instance == null)
        {
            _instance = this;
        }

        for (int i = 0; i < _spriteLists.Count; i++)
        {
            _characterSpritesDictionary.Add((Character)i, _spriteLists[i].sprites);
        }

        for (int i = 0; i < _spriteLists.Count; i++)
        {
            _characterSpriteDictionary.Add((Character)i, _spriteLists[i].texture);
        }
    }
Exemplo n.º 4
0
 private void Start()
 {
     characterSpriteManager = GetComponentInChildren <CharacterSpriteManager>();
 }
    void Update()
    {
        switch (state)
        {
        case State.Opening:
            // No matter what, when opening, just fade in the group
            managingGroup.alpha = Mathf.Clamp01(managingGroup.alpha + Time.deltaTime / fadeTime);
            if (managingGroup.alpha == 1)
            {
                state = State.Showing;
            }
            break;

        case State.Showing:
            // When showing we'll care about the shown group
            if (managingGroup == dialogGroup)
            {
                // If showing a fragment, show more characters until all of them are displayed
                if (Input.GetMouseButtonDown(0))
                {
                    if (charactersShown < msg.Length)
                    {
                        charactersShown = msg.Length;
                        UpdateText();
                    }
                    else
                    {
                        state = State.Closing;
                    }
                }

                accumulated += Time.deltaTime;
                while (accumulated > timePerCharacter)
                {
                    accumulated    -= timePerCharacter;
                    charactersShown = Mathf.Clamp(charactersShown + 1, 0, msg.Length);
                    UpdateText();
                }

                if (currentCharacter)
                {
                    currentCharacter.Talking = charactersShown < msg.Length;
                }

                var scrollpos = new Vector2(scroll.value, 0);
                scrollpos    = Vector2.SmoothDamp(scrollpos, new Vector2(scrollWantsToBe, 0), ref speed, scrollTime, scrollSpeed, Time.deltaTime);
                scroll.value = scrollpos.x;
            }
            else if (managingGroup == optionsGroup)
            {
                if (optionSelected != null)
                {
                    state = State.Closing;
                }
            }

            break;

        case State.Closing:
            // No matter what, when closing, just fade out the displayed group
            managingGroup.alpha = Mathf.Clamp01(managingGroup.alpha - Time.deltaTime / fadeTime);
            if (managingGroup.alpha == 0)
            {
                faceCamera.character = null;
                managingGroup.gameObject.SetActive(false);
                currentCharacter = null;
                interactionBlocker.SetActive(false);
                state           = State.Idle;
                textHolder.text = "";
                textHolder.rectTransform.anchoredPosition = Vector2.zero;
                frg   = null;
                speed = Vector2.zero;
                foreach (var io in instancedOptions)
                {
                    GameObject.DestroyImmediate(io);
                }
            }
            break;

        case State.Idle:
            break;
        }
    }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     spriteManager = GetComponent <CharacterSpriteManager>();
     ResetTimeToBlink();
 }
Exemplo n.º 7
0
 private void Awake()
 {
     Instance = this;
 }
Exemplo n.º 8
0
        public override void draw(SpriteBatch spriteBatch)
        {
            MouseState ms        = Mouse.GetState();
            Color      tileColor = Color.White;

            //if (ms.LeftButton == ButtonState.Pressed) tileColor = Color.LightPink;

            for (int j = 0; j < tManager.getTowerTypeCount(); ++j)
            {
                Vector2 pos = new Vector2(700.0f, 100.0f + j * 100.0f);
                if (eManager.isPaused())
                {
                    drawTexture(spriteBatch, "character-bits", pos, 0.0f, Vector2.Zero, CharacterSpriteManager.getBody(0), 4.0f, Color.White);
                }
                else
                {
                    drawTexture(spriteBatch, "character-bits", pos, 0.0f, Vector2.Zero, CharacterSpriteManager.getBody(4), 4.0f, Color.White);
                }
            }

            for (int i = 0; i < MapManager.getTileCount(); ++i)//this should switch to the level loader???
            {
                int xPos = (i % 20) * 32;
                int yPos = (i / 20) * 32;

                int[] testMap = levelManager.getMap();

                if (ms.X >= xPos && ms.X < xPos + 32 && ms.Y >= yPos && ms.Y < yPos + 32 && ms.LeftButton == ButtonState.Pressed)
                {
                    if (testMap[i] >= 3 && testMap[i] <= 11)
                    {
                        tileColor = Color.LightPink;
                    }
                    else
                    {
                        tileColor = Color.LightBlue;
                    }

                    parent.game.setMouseColor(tileColor);
                }
                else
                {
                    tileColor = Color.White;
                }

                //draw all the grass
                int j = i / 20;
                if ((i + j) % 2 == 0)
                {
                    spriteBatch.Draw(aManager.getTexture("map-tiles"), new Vector2(xPos, yPos), MapManager.getTile(0), tileColor, 0.0f, new Vector2(), 2.0f, SpriteEffects.None, 0.0f);
                }
                else
                {
                    spriteBatch.Draw(aManager.getTexture("map-tiles"), new Vector2(xPos, yPos), MapManager.getTile(1), tileColor, 0.0f, new Vector2(), 2.0f, SpriteEffects.None, 0.0f);
                }

                //draw roads from the map above
                if (testMap[i] > 1) //not a grass tile
                {
                    spriteBatch.Draw(aManager.getTexture("map-tiles"), new Vector2(xPos, yPos), MapManager.getTile(testMap[i]), tileColor, 0.0f, new Vector2(), 2.0f, SpriteEffects.None, 0.0f);
                }
            }

            if (tManager.getSelectedTowerType() >= 0)
            {
                drawTexture(spriteBatch, "character-bits", new Vector2(ms.X - 16, ms.Y - 16), 0.0f, Vector2.Zero, CharacterSpriteManager.getBody(0), 2.0f, parent.game.getMouseColor());
            }

            for (int i = 0; i < tManager.getTowerCount(); ++i)
            {
                Tower t = tManager.getTower(i);
                drawTexture(spriteBatch, "character-bits", t.position, 0.0f, new Vector2(0.0f, 8.0f), CharacterSpriteManager.getBody(0), 2.0f, Color.White);
            }

            for (int i = 0; i < tManager.getBulletCount(); ++i)
            {
                Bullet t = tManager.getBullet(i);
                drawTexture(spriteBatch, "character-bits", t.position, 0.0f, new Vector2(8.0f, 8.0f), CharacterSpriteManager.getBody(0), 2.0f, Color.White);
            }

            for (int i = eManager.getCount() - 1; i >= 0; --i)
            {
                Entity e = eManager.getEntity(i);
                if (e != null)
                {
                    float adjustedAngle = e.rotationAngle + e.rotationOffset;

                    if (e.spriteIndexes[0] >= 0)
                    {
                        drawTexture(spriteBatch, e.spriteId, e.position, adjustedAngle, e.center, CharacterSpriteManager.getBody(e.spriteIndexes[0]), 2.0f, Color.White);
                    }
                    if (e.spriteIndexes[2] >= 0)
                    {
                        drawTexture(spriteBatch, e.spriteId, e.position, adjustedAngle, e.center, CharacterSpriteManager.getPants(e.spriteIndexes[2]), 2.0f, Color.White);
                    }
                    if (e.spriteIndexes[1] >= 0)
                    {
                        drawTexture(spriteBatch, e.spriteId, e.position, adjustedAngle, e.center, CharacterSpriteManager.getShirt(e.spriteIndexes[1]), 2.0f, Color.White);
                    }
                    if (e.spriteIndexes[3] >= 0)
                    {
                        drawTexture(spriteBatch, e.spriteId, e.position, adjustedAngle, e.center, CharacterSpriteManager.getHeadpiece(e.spriteIndexes[3]), 2.0f, Color.White);
                    }
                    if (e.spriteIndexes[4] >= 0)
                    {
                        drawTexture(spriteBatch, e.spriteId, e.position, adjustedAngle, e.center, CharacterSpriteManager.getWeapon(e.spriteIndexes[4]), 2.0f, Color.White);
                    }
                    if (e.spriteIndexes[5] >= 0)
                    {
                        drawTexture(spriteBatch, e.spriteId, e.position, adjustedAngle, e.center, CharacterSpriteManager.getShield(e.spriteIndexes[5]), 2.0f, Color.White);
                    }
                }
            }
        }