Ejemplo n.º 1
0
    public void FlipCharacterSprite(string characterLabel)
    {
        VsnCharacter character = FindCharacterByLabel(characterLabel);

        if (character == null)
        {
            Debug.LogError("Error flipping character " + characterLabel + ". Character not found with this label.");
            return;
        }

        Vector3 localScale = character.transform.localScale;

        character.transform.localScale = new Vector3(localScale.x * -1f, localScale.y, localScale.z);
    }
Ejemplo n.º 2
0
    public void CreateNewCharacter(Sprite characterSprite, string characterFilename, string characterLabel)
    {
        GameObject vsnCharacterObject = Instantiate(vsnCharacterPrefab, charactersPanel.transform) as GameObject;

        vsnCharacterObject.transform.localScale = Vector3.one;
        VsnCharacter vsnCharacter = vsnCharacterObject.GetComponent <VsnCharacter>();

        Vector2 newPosition = Vector2.zero;

        vsnCharacter.GetComponent <RectTransform>().anchoredPosition = newPosition;

        vsnCharacter.GetComponent <Image>().sprite = characterSprite;
        vsnCharacter.label             = characterLabel;
        vsnCharacter.characterFilename = characterFilename;

        characters.Add(vsnCharacter);
    }
Ejemplo n.º 3
0
    public void MoveCharacterY(string characterLabel, float position, float duration)
    {
        float        screenPosition = GetCharacterScreenPositionY(position);
        VsnCharacter character      = FindCharacterByLabel(characterLabel);

        if (character != null)
        {
            Vector2 newPosition = new Vector2(character.GetComponent <RectTransform>().anchoredPosition.x, screenPosition);
            if (duration != 0)
            {
                character.GetComponent <RectTransform>().DOAnchorPos(newPosition, duration);
            }
            else
            {
                character.GetComponent <RectTransform>().anchoredPosition = newPosition;
            }
        }
    }
Ejemplo n.º 4
0
    public void SetCharacterAlpha(string characterLabel, float alphaValue, float duration)
    {
        VsnCharacter character = FindCharacterByLabel(characterLabel);

        if (character != null)
        {
            Image characterImage = character.GetComponent <Image>();
            if (duration != 0)
            {
                characterImage.DOFade(alphaValue, duration);
            }
            else
            {
                characterImage.color = new Color(characterImage.color.r,
                                                 characterImage.color.g,
                                                 characterImage.color.b, alphaValue);
            }
        }
    }
Ejemplo n.º 5
0
    public void MoveCharacterX(string characterLabel, float position, float duration)
    {
        float        screenPosition = GetCharacterScreenPositionX(position);
        VsnCharacter character      = FindCharacterByLabel(characterLabel);

        Debug.LogWarning("Original pos: " + position + ", final pos: " + screenPosition);

        if (character != null)
        {
            Vector2 newPosition = new Vector2(screenPosition, character.GetComponent <RectTransform>().anchoredPosition.y);
            if (duration != 0)
            {
                character.GetComponent <RectTransform>().DOAnchorPos(newPosition, duration);
            }
            else
            {
                character.GetComponent <RectTransform>().anchoredPosition = newPosition;
            }
        }
    }