protected override void OnHandleEvent(IEventMessage msg)
    {
        if (msg is BattleEvent.DamageHurt)
        {
            if (CharData.IsDead == false)
            {
                BattleEvent.DamageHurt message = msg as BattleEvent.DamageHurt;
                CharData.DamageHurt(message.Damage);
                CharAnim.Play("getHit");

                // 随机播放角色受击音效
                string soundName = Avatar.GetRandomGetHitSound();
                if (string.IsNullOrEmpty(soundName) == false)
                {
                    AudioManager.Instance.PlaySound(soundName);
                }
            }
        }
        else if (msg is BattleEvent.CharacterDead)
        {
            CharSkill.ForbidAll();
            CharAnim.Play("die");

            // 播放角色死亡音效
            string soundName = Avatar.GetDeadSound();
            if (string.IsNullOrEmpty(soundName) == false)
            {
                AudioManager.Instance.PlaySound(soundName);
            }
        }
    }
    //private Attack weapon;

    // Use this for initialization
    void Start()
    {
        GameObject obj = GameObject.FindWithTag("GameController");

        gameController = obj.GetComponent <RandomDrop>();
        //GameObject wpn = GameObject.FindWithTag ("Weapon");
        //weapon = wpn.GetComponent<Attack> ();
        //weapon = GetComponent<Attack> ();
        GameObject[] model = GameObject.FindGameObjectsWithTag("Animated");

        if (model == null)
        {
            Debug.Log("no model");
        }
        foreach (GameObject m in model)
        {
            Debug.Log(m.name);
            anim = m.GetComponent <CharAnim> ();
            if (anim == null)
            {
                Debug.Log("no anim");
            }
        }

        wings.SetActive(false);
        boltcarry.SetActive(false);
    }
示例#3
0
    protected override void OnPrepareAvatar()
    {
        base.OnPrepareAvatar();

        CharAnim.InitAnimState("idle02", CharacterAnimation.EAnimationLayer.DefaultLayer, WrapMode.Loop);
        CharAnim.InitAnimState("idle03", CharacterAnimation.EAnimationLayer.DefaultLayer, WrapMode.Loop);
        CharAnim.InitAnimState("walk", CharacterAnimation.EAnimationLayer.DefaultLayer, WrapMode.Loop);
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        collider.enabled = false;
        timer            = timeBetweenAttacks;
        spawner          = GetComponent <SpawnOnTriggerCollision> ();
        wpnAnim          = wpn.GetComponent <WeaponAnim> ();
        GameObject model = GameObject.FindWithTag("Animated");

        anim = model.GetComponent <CharAnim> ();
        //wpn.SetActive (false);
    }
示例#5
0
    void Start( )
    {
        if (useLivesOnly)
        {
            maxHealth      = 1.0f;
            startingHealth = 1.0f;
        }
        if (this.tag == "Enemy")
        {
            anim = GetComponent <MyAnimator> ();
        }
        currentHealth = startingHealth;
        GameObject obj = GameObject.FindWithTag("GameController");

        gameController = obj.GetComponent <WinLoseMessage> ();
        GameObject model = GameObject.FindWithTag("Animated");

        charAnim = model.GetComponent <CharAnim> ();
    }
示例#6
0
    /// <summary>
    /// Rozpoczyna animację.
    /// </summary>
    /// <param name="ann">Tekst</param>
    /// <param name="fontSize">Rozmiar czcionki</param>
    /// <param name="align">Ułożenie.</param>
    public void setText(string ann, int fontSize = 35, TextAnchor align = TextAnchor.MiddleLeft)
    {
        if (text != null)
        {
            return;                       // Jeżeli ktoś błędnie użyje dwa razy setText na tym samym elemencie, to return
        }
        textcmp.fontSize  = fontSize;
        textcmp.alignment = align;
        //textcmp.rectTransform - później

        // Przekonwertowanie string do CharAnim[]
        text = new CharAnim[ann.Length];
        for (int i = 0; i < ann.Length; i++)
        {
            CharType type = Symbol;

            foreach (CharType t in Types)
            {
                if (t.isType(ann [i]))
                {
                    type = t;
                    break;
                }
            }

            text [i] = new CharAnim(ann [i], type);
        }

        // Stworzenie tablicy zawierająca losowo ułożone indeksy zmiennej CharAnim[] Text
        removeRandom = new int[text.Length];
        for (int i = 0; i < text.Length; i++)
        {
            removeRandom [i] = i;
        }
        // LINQ -> miesza tablicę
        removeRandom = removeRandom.OrderBy(
            x => Random.Range(0, text.Length)
            ).ToArray();
    }
    protected override void OnUpdateAvatar(float deltaTime)
    {
        if (CharSkill.IsAnyLife())
        {
            return;
        }

        if (CharMove.IsMoving)
        {
            float animSpeed = CharData.MoveSpeed / Avatar.GetRunAnimationSpeed();
            CharAnim.SetSpeed(CharData.CurrentRunAnimName, animSpeed);
            if (CharAnim.IsPlaying(CharData.CurrentRunAnimName) == false)
            {
                CharAnim.Play(CharData.CurrentRunAnimName, 0.15f);
            }
        }
        else
        {
            if (CharAnim.IsPlaying(CharData.CurrentIdleAnimName) == false)
            {
                CharAnim.Play(CharData.CurrentIdleAnimName, 0.15f);
            }
        }
    }