Exemplo n.º 1
0
    protected void onRefreshResourceClick(GameObject obj)
    {
        // 从数据库中查找
        mResourceList.Clear();
        List <EffectData> dataList;

        mSQLiteEffect.queryAll(out dataList);
        int count = dataList.Count;

        for (int i = 0; i < count; ++i)
        {
            EffectAtlas effectAtlas = new EffectAtlas();
            effectAtlas.mAtlasName   = dataList[i].mResource;
            effectAtlas.mAnimSetList = new List <EffectAnim>();
            List <EffectFrameData> frameDataList;
            mSQLiteEffectFrame.query(dataList[i].mID, out frameDataList);
            int frameDataCount = frameDataList.Count;
            for (int j = 0; j < frameDataCount; ++j)
            {
                EffectAnim anim = new EffectAnim();
                anim.mID         = frameDataList[j].mID;
                anim.mAction     = frameDataList[j].mAction;
                anim.mDirection  = frameDataList[j].mDirection;
                anim.mTextureSet = frameDataList[j].mAction + "_dir" + frameDataList[j].mDirection;
                effectAtlas.mAnimSetList.Add(anim);
            }
            mResourceList.Add(effectAtlas);
        }
        mEffectCount.setLabel("图集数量:0/" + mResourceList.Count);
        // 设置
        setCurAtlas(0);
    }
Exemplo n.º 2
0
    protected override IEnumerator Run(MainSystem sys)
    {
        // 攻撃キャラを、ターゲットの中間に移動させる(攻撃アニメーションの代替)
        var src = Actor.Position;
        var dst = src;

        dst.x          = (src.x + _target.Position.x) / 2;
        dst.y          = (src.y + _target.Position.y) / 2;
        Actor.Position = dst;

        var rand = new Random();
        var dmg  = 20 + rand.Next(-2, 5);

        _target.RemoveStatus(StatusType.Sleep);
        // TODO:Func<IEnumerator> ではなくて、IEnumerator を渡す
        yield return(Anim.Par(sys,
                              () => _target.DamageAnim(dmg),
                              () => EffectAnim.PopupWhiteDigits(_target, dmg)));

        _target.DamageHp(dmg);
        Actor.Position = src;

        if (_target.Hp <= 0)   // 敵を倒したときに爆発アニメーション
        {
            var pos = _target.Position;
            _target.Destroy();
            yield return(EffectAnim.Dead(pos));
        }
    }
Exemplo n.º 3
0
    protected override IEnumerator Run(MainSystem sys)
    {
        // 攻撃キャラを、ターゲットとの中間に移動させる(攻撃アニメーションの代替)
        var src = Actor.Position;
        var dst = src;

        dst.x          = (src.x + _target.Position.x) / 2;
        dst.y          = (src.y + _target.Position.y) / 2;
        Actor.Position = dst;

        // ターゲットの方を向く
        Actor.ChangeDir(Actor.Loc.Toward(_target.Loc));
        _target.HideDirection();

        // ターゲットは攻撃者の方を向く。ただし以下の場合は振り向かない
        // - 目の前に敵が存在する
        // - 攻撃者が透明状態
        if (!sys.ExistsEnemy(_target.Front()) && !Actor.IsInvisible())
        {
            _target.ChangeDir(_target.Loc.Toward(Actor.Loc));
        }

        _target.RemoveStatus(StatusType.Sleep);
        var dmg = 16 + new System.Random().Next(30);

        yield return(Anim.Par(sys,
                              () => _target.DamageAnim(dmg),
                              () => EffectAnim.PopupWhiteDigits(_target, dmg)));

        _target.DamageHp(dmg);
        Actor.Position = src;
    }
Exemplo n.º 4
0
    public override IEnumerator RunAnimation(CharacterBase sender, MainSystem sys)
    {
        yield return(EffectAnim.Landmine(sender.Position));

        var enemies     = sys.CollectNeighborEnemies(sender.Loc);
        var damageAnims = new List <DamageWait>();

        damageAnims.Add(new DamageWait(sender, Math.Max(1, sender.Hp - 1), sys));
        for (int i = 0; i < enemies.Length; i++)
        {
            damageAnims.Add(new DamageWait(enemies[i], 99, sys));
        }

        while (true)
        {
            bool finished = true;
            foreach (var d in damageAnims)
            {
                finished = finished && d.AnimationFinished;
            }

            if (finished)
            {
                break;
            }
            yield return(null);
        }
    }
Exemplo n.º 5
0
    public IEnumerator Summon(Loc loc)
    {
        // TODO: assert(loc に敵がいない)
        var e = EnemyFactory.CreateEnemy(loc);

        _enemies.Add(e);

        yield return(Anim.Par(this,
                              () => e.FadeIn(),
                              () => EffectAnim.Aura2(e.Position)));
    }
Exemplo n.º 6
0
    public override IEnumerator Use(CharacterBase sender, MainSystem sys)
    {
        yield return(EffectAnim.Aura(sender.Position));

        sys.HideMinimap();

        // 黒マスクで画面全体を暗くする
        var mask = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Mask/black"), sender.Position, Quaternion.identity);

        mask.transform.localScale = new Vector3(10f, 15f, 1);

        float cameraZoomDelta = 0.65f;

        yield return(Anim.Par(sys,
                              () => sys.CameraZoomOut(cameraZoomDelta),
                              () => MaskFade(mask, 0, 0.5f)));

        yield return(Anim.Par(sys,
                              () => CAction.Quake(GameObject.Find(LayerName.Map), 1.4f),
                              () => EffectAnim.Skill(sender.Position)));

        yield return(new WaitForSeconds(0.3f));

        yield return(Anim.Par(sys,
                              () => sys.CameraZoomIn(cameraZoomDelta),
                              () => MaskFade(mask, 0.5f, 0)));

        GameObject.Destroy(mask);

        sys.ShowMinimap();

        var enemies     = sys.GetEnemies();
        var damageAnims = new List <DamageWait>();

        for (int i = 0; i < enemies.Length; i++)
        {
            damageAnims.Add(new DamageWait(enemies[i], 99, sys));
        }

        while (true)
        {
            bool finished = true;
            foreach (var d in damageAnims)
            {
                finished = finished && d.AnimationFinished;
            }

            if (finished)
            {
                break;
            }
            yield return(null);
        }
    }
Exemplo n.º 7
0
    public override IEnumerator RunAnimation(CharacterBase sender, MainSystem sys)
    {
        yield return(EffectAnim.Heal(sender.Position));

        var healHp = 10 + new System.Random().Next(27);

        yield return(Anim.Par(sys,
                              () => sender.HealAnim(healHp),
                              () => EffectAnim.PopupGreenDigits(sender, healHp)));

        sender.HealHp(healHp);
    }
Exemplo n.º 8
0
    public override IEnumerator Hit(CharacterBase sender, CharacterBase target, MainSystem sys)
    {
        Debug.LogFormat("入れ替え sender:{0} target:{1}", sender, target);

        Assert.IsTrue(sender != null && target != null);
        var loc1 = sender.Loc;
        var loc2 = target.Loc;

        yield return(Anim.Par(sys,
                              () => EffectAnim.Warp(loc1.ToPosition()),
                              () => EffectAnim.Warp(loc2.ToPosition())));

        sender.UpdateLoc(loc2);
        target.UpdateLoc(loc1);
        yield return(new WaitForSeconds(0.4f));
    }
Exemplo n.º 9
0
    protected void setCurAnim(int index)
    {
        if (index < 0 || index >= mResourceList[mAtlasIndex].mAnimSetList.Count)
        {
            return;
        }
        mAnimIndex = index;
        EffectAtlas curAtlas  = mResourceList[mAtlasIndex];
        EffectAnim  curAnim   = curAtlas.mAnimSetList[mAnimIndex];
        float       playSpeed = stringToFloat(mPlaySpeed.getText());

        mEffectSpriteInstance.play(curAnim.mTextureSet, findPosList(curAnim), mPlayLoop.getChecked(), playSpeed);
        mEffectName.setText(curAtlas.mAtlasName + "/" + curAnim.mTextureSet);
        checkPause();
        mAnimCount.setLabel("序列帧数量:" + (mAnimIndex + 1) + "/" + curAtlas.mAnimSetList.Count);
    }
Exemplo n.º 10
0
    private IEnumerator Run(MainSystem sys)
    {
        _target.RemoveStatus(StatusType.Sleep);
        yield return(Anim.Par(sys,
                              () => _target.DamageAnim(_damage),
                              () => EffectAnim.PopupWhiteDigits(_target, _damage)));

        _target.DamageHp(_damage);
        if (_target.Hp <= 0 && _target is Enemy)
        {
            var pos = _target.Position;
            _target.Destroy();
            yield return(EffectAnim.Dead(pos));
        }
        AnimationFinished = true;
    }
Exemplo n.º 11
0
    public override IEnumerator Hit(CharacterBase sender, CharacterBase target, MainSystem sys)
    {
        yield return(EffectAnim.Thunder(target.Position));

        int damage = 99;

        yield return(Anim.Par(sys,
                              () => target.DamageAnim(damage),
                              () => EffectAnim.PopupWhiteDigits(target, damage)));

        target.DamageHp(damage);

        if (target.Hp <= 0 && target is Enemy)
        {
            var pos = target.Position;
            target.Destroy();
            yield return(EffectAnim.Dead(pos));
        }
    }
Exemplo n.º 12
0
    protected List <Vector2> findPosList(EffectAnim anim)
    {
        List <EffectFrameData> effectDataList;

        mSQLiteEffectFrame.query(anim.mID, anim.mDirection, anim.mAction, out effectDataList);
        if (effectDataList.Count != 1)
        {
            logError("effect frame error!");
            return(null);
        }
        List <Vector2> posList = new List <Vector2>();

        for (int j = 0; j < effectDataList[0].mFrameCount; ++j)
        {
            // 由于坐标系不一致,所以需要将Y方向偏移取反
            posList.Add(new Vector2(effectDataList[0].mPosX[j], -effectDataList[0].mPosY[j]));
        }
        return(posList);
    }
Exemplo n.º 13
0
    public override IEnumerator RunAnimation(CharacterBase sender, MainSystem sys)
    {
        var dmg = 10 + new System.Random().Next(5);

        yield return(EffectAnim.PopupWhiteDigits(sender, dmg));
    }