コード例 #1
0
    //在表中寻找特定特效
    private GameEffect FGetEffect(string name)
    {
        if (!effectPool.ContainsKey(name))
        {
            Debug.LogError("No Such Effect " + name);
            return(null);
        }

        List <GameEffect> pool           = effectPool[name];
        GameEffect        restGameEffect = null;

        for (int i = 0; i < pool.Count; i++)
        {
            GameEffect ge = pool[i];
            if (ge.gameObject.activeSelf)
            {
                continue;
            }
            restGameEffect = ge;
            break;
        }

        if (!restGameEffect)
        {
            restGameEffect = FCreateEffect(name, effectConfig.Target[name]);
        }
        return(restGameEffect);
    }
コード例 #2
0
    GameEffect GetEffect(string effectName, Vector3 worldPos)
    {
        GameEffect ret = null;

        if (effectPool.ContainsKey(effectName))
        {
            List <GameEffect> pool = effectPool[effectName];
            for (int i = 0; i < pool.Count; i++)
            {
                GameEffect eff = pool[i];

                if (eff.gameObject.activeSelf)
                {
                    continue;
                }
                eff.transform.position = worldPos;
                ret = eff;
                break;
            }
        }

        if (ret == null)
        {
            GameEffect eff = CreateEffect(effectName, worldPos);
            if (eff != null)
            {
                ret = eff;
            }
        }

        return(ret);
    }
コード例 #3
0
    private bool operationHandler(string from, string to, string cardStr)
    {
        if (this.currentGameState != GameState.UserAction)
        {
            return(false);
        }
        LilyAcolasia.GameInput input = this.gameEnumerator.Current;

        if (from.Contains("Hand") && to.Contains("Field"))
        {
            int field = to[to.IndexOf("Field") + 5] - '0';
            input.input(LilyAcolasia.Command.Discard, cardStr, field.ToString());
        }
        else if (from.Contains("Field") && to == "Trash")
        {
            int field = from[from.IndexOf("Field") + 5] - '0';
            LilyAcolasia.CardGame game = this.gameOperator.Round.Current;
            if (game.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
            {
                if (game.LastTrashed.Power == 5)
                {
                    return(false);
                }
                input.input(LilyAcolasia.Command.Special, cardStr, field.ToString());
            }
            else
            {
                input.input(LilyAcolasia.Command.Trash, cardStr, field.ToString());
            }
        }
        else if (from.Contains("Hand") && to == "Trash" && this.gameOperator.Round.Current.IsFilled)
        {
            input.input(LilyAcolasia.Command.Next);
            this.gameEnumerator.MoveNext();
            return(false);
        }
        else
        {
            return(false);
        }

        this.gameEnumerator.MoveNext();
        Debug.Log(gameOperator.Round.Current.ToString());
        Debug.Log(gameOperator.Round.Current.Status.ToString());

        GameEffect.Special(-1, gameOperator.Round.Current.Turn);
        if (this.gameOperator.Round.Current.Status == LilyAcolasia.GameStatus.Status.WaitSpecialInput)
        {
            GameEffect.CutIn(this.gameOperator.Round.Current.LastTrashed.Power);
            audioSource.clip = soundCutIn;
            audioSource.Play();
            this.currentGameState = GameState.CutIn;
        }
        else
        {
            this.currentGameState = GameState.CmdWait;
        }

        return(this.observer.IsCmdSuccess);
    }
コード例 #4
0
    // 检查特效是否还有效,特效物体已经被销毁的视为无效特效,将被清除
    public void clearInvalidEffect()
    {
        LIST(out List <GameEffect> tempList);
        tempList.AddRange(mEffectList);
        int count = tempList.Count;

        for (int i = 0; i < count; ++i)
        {
            GameEffect effect = tempList[i];
            // 虽然此处isValidEffect已经足够判断特效是否还存在
            // 但是这样逻辑不严谨,因为依赖于引擎在销毁物体时将所有的引用都置为空
            // 这是引擎自己的特性,并不是通用操作,所以使用更严谨一些的判断
            bool effectValid;
            if (effect.isExistObject())
            {
                effectValid = effect.isValidEffect();
            }
            else
            {
                effectValid = mObjectPool.isExistInPool(effect.getObject());
                // 如果特效物体不是空的,可能是销毁物体时引擎不是立即销毁的,需要手动设置为空
                if (!effectValid && effect.getObject() != null)
                {
                    effect.setObject(null);
                }
            }
            if (!effectValid)
            {
                destroyEffect(ref effect);
            }
        }
        UN_LIST(tempList);
    }
コード例 #5
0
        public void Update(double totalMS, double frameMS)
        {
            GameEffect f = _root;

            while (f != null)
            {
                LinkedObject n = f.Next;

                f.Update(totalMS, frameMS);

                if (!f.IsDestroyed && f.Distance > World.ClientViewRange)
                {
                    RemoveEffect(f);
                }

                if (f.IsDestroyed)
                {
                    if (f.Children.Count != 0)
                    {
                        foreach (GameEffect child in f.Children)
                        {
                            if (!child.IsDestroyed)
                            {
                                Add(child);
                            }
                        }

                        f.Children.Clear();
                    }
                }

                f = (GameEffect)n;
            }
        }
コード例 #6
0
 public void Add(GameEffect effect)
 {
     if (effect != null)
     {
         _effects.Add(effect);
     }
 }
コード例 #7
0
ファイル: EffectFactory.cs プロジェクト: McGake/Space-Liver
    public static GameEffect CreateGameEffect(GameEffect.EffectType type, float delay = 3f)
    {
        GameEffect newEffect = new GameEffect(type, delay);

        switch (type)
        {
        case GameEffect.EffectType.KillPlayer:
            newEffect.onActivate = KillPlayer;
            break;

        case GameEffect.EffectType.VentAir:
            newEffect.onActivate = VentAir;
            break;

        case GameEffect.EffectType.HoldBreath:
            newEffect.onActivate = HoldBreath;
            break;

        case GameEffect.EffectType.Cry:
            newEffect.onActivate = Cry;
            break;

        case GameEffect.EffectType.Explode:
            newEffect.onActivate = Explode;
            break;

        case GameEffect.EffectType.Flail:
            newEffect.onActivate = Flail;
            break;
        }



        return(newEffect);
    }
コード例 #8
0
ファイル: ActionsPanel.cs プロジェクト: McGake/Space-Liver
    public void PopulateActions()
    {
        for (int i = 0; i < 4; i++)
        {
            int randomEntry = Random.Range(0, actionsDatabase.actionData.Count);

            for (int x = 0; x < actions.Count; x++)
            {
                //Debug.Log(actions[x].actionNameText.text + " " + actionsDatabase.actionData[randomEntry].actionName);
                while (actions[x].actionNameText.text == actionsDatabase.actionData[randomEntry].actionName)
                {
                    //Debug.Log("messed up here");
                    randomEntry = Random.Range(0, actionsDatabase.actionData.Count);
                    x           = 0;
                }
            }
            Debug.Log("actions " + i + "is" + actionsDatabase.actionData[randomEntry].actionName);

            GameObject newEntry = Instantiate(actionEntryTemplate.gameObject) as GameObject;
            newEntry.transform.SetParent(actionEntryHolder, false);
            newEntry.GetComponent <Image>().sprite = spriteButtons[i];
            newEntry.SetActive(true);

            ActionEntry entryScript = newEntry.GetComponent <ActionEntry>();
            GameEffect  testEfect   = EffectFactory.CreateGameEffect(actionsDatabase.actionData[randomEntry].testSimpleEffect, actionsDatabase.actionData[randomEntry].delay);

            entryScript.Initialize(actionsDatabase.actionData[randomEntry], testEfect, this);
            actions.Add(entryScript);
        }
    }
コード例 #9
0
    // 检查特效是否还有效,特效物体已经被销毁的视为无效特效,将被清除
    public void clearInvalidEffect()
    {
        List <GameEffect> tempList = mListPool.newList(out tempList);

        tempList.AddRange(mEffectList);
        foreach (var item in tempList)
        {
            GameEffect effect = item;
            // 虽然此处isValidEffect已经足够判断特效是否还存在
            // 但是这样逻辑不严谨,因为依赖于引擎在销毁物体时将所有的引用都置为空
            // 这是引擎自己的特性,并不是通用操作,所以使用更严谨一些的判断
            bool effectValid;
            if (effect.isExistObject())
            {
                effectValid = effect.isValidEffect();
            }
            else
            {
                effectValid = mObjectPool.isExistInPool(effect.getObject());
                // 如果特效物体不是空的,可能是销毁物体时引擎不是立即销毁的,需要手动设置为空
                if (!effectValid && effect.getObject() != null)
                {
                    effect.setObject(null);
                }
            }
            if (!effectValid)
            {
                destroyEffect(ref effect);
            }
        }
        mListPool.destroyList(tempList);
    }
コード例 #10
0
        public void RemoveEffect(GameEffect effect)
        {
            if (effect == null || effect.IsDestroyed)
            {
                return;
            }

            if (effect.Previous == null)
            {
                _root = (GameEffect)effect.Next;

                if (_root != null)
                {
                    _root.Previous = null;
                }
            }
            else
            {
                effect.Previous.Next = effect.Next;

                if (effect.Next != null)
                {
                    effect.Next.Previous = effect.Previous;
                }
            }

            effect.Next     = null;
            effect.Previous = null;
            effect.Destroy();
        }
コード例 #11
0
    GameEffect GetEffect(int effectid, Vector3 worldPos)
    {
        //对应池是否存在
        if (!effectPool.ContainsKey(effectid))
        {
            return(null);
        }


        //寻找空闲特效
        List <GameEffect> pool = effectPool[effectid];
        GameEffect        ret  = null;

        for (int i = 0; i < pool.Count; i++)
        {
            GameEffect eff = pool[i];

            if (eff.gameObject.activeSelf)
            {
                continue;
            }

            ret = eff;
            break;
        }

        return(ret);
    }
コード例 #12
0
ファイル: GameEffectManager.cs プロジェクト: kkomler/Test-1
    //添加一个特效到缓存池
    GameEffect CreateEffect(conf_effect effect)
    {
        Object obj = Resources.Load(effect.file_path);

        if (obj == null)
        {
            Debug.LogError("cant find file ! : " + effect.file_path);
        }
        if (effect.res_type == 1)
        {
            GameObject go = (GameObject)MonoBehaviour.Instantiate(obj);

            GameEffect ge = go.AddComponent <GameEffect>();
            ge.Init(effect);

            if (!effectPool.ContainsKey(effect.id))
            {
                effectPool.Add(effect.id, new List <GameEffect>());
            }
            effectPool[effect.id].Add(ge);

            return(ge);
        }
        return(null);
    }
コード例 #13
0
    public void AddEffect(GameEffect.EffectType type, int value, object target = null)
    {
        GameEffect eff = GameEffect.CreateInstance <GameEffect>();

        eff.type  = type;
        eff.value = value;
        AddEffect(eff, target);
        Destroy(eff);
    }
コード例 #14
0
    public void Reset(GameEffect effect, object target = null)
    {
        this.effectType   = effect.type;
        this.effectValue  = effect.value;
        this.effectTarget = target;

        icon.sprite = IconSpriteFromType(effect.type);
        text.text   = (effect.value > 0 ? "+" : "") + effect.value + " " + effect.type;
    }
コード例 #15
0
 void ActivateEffect()
 {
     VFX_Explosion.SetActive(true);
     VFX_Explosion.transform.SetParent(transform.root);
     VFX_Explosion.GetComponent <ParticleSystem>().startColor = ColorList[CurrentSprite];
     VFX_Explosion.AddComponent <DelayDeath>().delay          = 5;
     GameEffect.FreezeFrame();
     GameEffect.Shake(Camera.main.gameObject, 0.5f, 0.4f);
 }
コード例 #16
0
    public void AddEffect(GameEffect effect, object target = null)
    {
        EffectUIComponent effectUIComponent = Instantiate(effectUIPrefab, stack);

        effectUIComponent.transform.SetAsFirstSibling();

        effectUIComponent.Reset(effect, target);
        _effects.Push(effectUIComponent);
    }
コード例 #17
0
 public void OnInteractableActionChange(InteractionPoint interactor, int action, StateChange state)
 {
     if (state == StateChange.Start)
     {
         if (action == castAction)
         {
             GameEffect.TriggerEffectsOnObject(effects, null, interactor.transform.position, interactor.baseInteractor.dynamicObject);
         }
     }
 }
コード例 #18
0
 void Start()
 {
     instance = this;
     fields   = new List <SpriteRenderer> ();
     foreach (Transform child in GameObject.Find("FieldWrapper").GetComponentInChildren <Transform>())
     {
         fields.Add(child.GetComponent <SpriteRenderer>());
     }
     audioSource = GetComponent <AudioSource> ();
 }
コード例 #19
0
    private void Update()
    {
        ChangeLineRendererDimension();

        if (Input.GetKeyDown(keyCodeShake))
        {
            GameEffect.ShakeModeSetPerlin(true, perlinSpeed);
            GameEffect.ShakeDynamic(transform.gameObject, shakeIntensity, shakeDuration);
        }
    }
コード例 #20
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.CompareTag("rocket"))
     {
         col.gameObject.GetComponent <Rocket>().DeathRocket();
         updateText();
         GameEffect.FlashSpriteLerp(gameObject, new Color32(150, 255, 255, 255), .2f);
         particle.Play();
     }
 }
コード例 #21
0
    // Clone
    public static GameEffect Clone(GameEffect original)
    {
        GameEffect cloneEffect = new GameEffect(
            boolParams: original.boolParams,
            floatParams: original.floatParams,
            stringParams: original.stringParams
            );

        return(cloneEffect);
    }
コード例 #22
0
 public void destroyEffect(ref GameEffect effect)
 {
     if (effect != null)
     {
         effect.setIgnoreTimeScale(false);
         effect.destroy();
         mEffectList.Remove(effect);
         mClassPool.destroyClass(effect);
         effect = null;
     }
 }
コード例 #23
0
 public void createEffectToPool(string nameWithPath, bool async, int tag)
 {
     if (async)
     {
         mObjectPool.createObjectAsync(nameWithPath, mPreloadEffectCallback, tag);
     }
     else
     {
         GameEffect effect = createEffect(nameWithPath, null, tag, false);
         destroyEffect(ref effect);
     }
 }
コード例 #24
0
    /// <summary>
    /// 添加特效到世界
    /// </summary>
    /// <returns>The world effect.</returns>
    /// <param name="effectid">Effectid.</param>
    /// <param name="pos">Position.</param>
    GameEffect AddWorldEffect(int effectid, Vector3 pos, float scale)
    {
        GameEffect ge = GetEffect(effectid, pos);

        if (ge == null)
        {
            return(null);
        }
        ge.transform.position = pos;
        ge.Play(scale);
        return(ge);
    }
コード例 #25
0
    /// <summary>
    /// Add static effect in somewhere of the scene
    /// </summary>
    /// <param name="effectName"></param>
    /// <param name="pos"></param>
    /// <param name="scale"></param>
    /// <param name="time"></param>
    /// <returns></returns>
    public GameEffect AddWorldEffect(string effectName, Vector3 pos, float scale, float time)
    {
        GameEffect ge = GetEffect(effectName);

        if (ge == null)
        {
            return(null);
        }
        ge.transform.position = pos;
        ge.Play(scale, time);
        return(ge);
    }
コード例 #26
0
 public void createEffectToPool(string nameWithPath, bool async, string tag)
 {
     if (async)
     {
         mObjectPool.createObjectAsync(nameWithPath, onPreLoadEffectLoaded, tag, null);
     }
     else
     {
         GameEffect effect = createEffect(nameWithPath, null, tag, false);
         destroyEffect(ref effect);
     }
 }
コード例 #27
0
    //将特效释放到特定位置
    public GameEffect FAddWorldEffect(string effectName, Vector3 pos, float scale = 1)
    {
        GameEffect ge = FGetEffect(effectName);

        if (!ge)
        {
            Debug.LogError("No such Effect " + effectName);
            return(null);
        }
        ge.transform.position = pos;
        ge.FPlay(scale);
        return(ge);
    }
コード例 #28
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.CompareTag("rocket"))
     {
         StartCoroutine(DelayDeath(.5f, true));
         inControl = false;
     }
     else if (col.gameObject.CompareTag("planet"))
     {
         GameEffect.Shake(Camera.main.gameObject, .1f, .2f);
         //GameEffect.FreezeFrame(.05f);
         DeathRocket();
     }
 }
コード例 #29
0
        public new void Clear()
        {
            GameEffect first = (GameEffect)Items;

            while (first != null)
            {
                LinkedObject n = first.Next;

                first.Destroy();

                first = (GameEffect)n;
            }

            Items = null;
        }
コード例 #30
0
    /// <summary>
    /// 添加特效到服务器
    /// </summary>
    /// <returns>The world effect.</returns>
    /// <param name="effectid">Effectid.</param>
    /// <param name="pos">Position.</param>
    GameEffect AddEffect(int effectid, GameObject obj, Vector3 pos, float scale)
    {
        if (obj == null)
        {
            return(AddWorldEffect(effectid, pos, scale));
        }
        GameEffect ge = GetEffect(effectid, obj.transform.position + pos);

        if (ge == null)
        {
            return(null);
        }
        ge.SetParent(obj);
        ge.Play(scale);
        return(ge);
    }
コード例 #31
0
ファイル: NodeController.cs プロジェクト: GotoK/H401
    // Use this for initialization
    void Start()
    {
        ////Log.Debug("Start");

        //音声データを取得 添字をenum化すべきか
        audioSources = GetComponents<AudioSource>();
        /*if (audioSources.Length != (int)_eAudioNumber.MAX)
            print("音声取得に失敗");*/

        // ----- プレハブデータを Resources から取得
        gameNodePrefab = Resources.Load<GameObject>(gameNodePrefabPath);
        frameNodePrefab = Resources.Load<GameObject>(frameNodePrefabPath);
        gameArrowPrefab = Resources.Load<GameObject>(gameArrowPrefabPath);

        // ----- スプライトデータを Resources から取得
        gameNodeSprite = Resources.LoadAll<Sprite>(gameNodeSpritePath);
        nodeMaskSprite = Resources.LoadAll<Sprite>(nodeMaskSpritePath);
        frameNodeSprite = Resources.LoadAll<Sprite>(frameNodeSpritePath);

        // GameEffect スクリプトを取得
        gameEffect = transform.GetComponent<GameEffect>();

        // ----- ノード準備
        NodeTemplate.AllCalc(NodeTemp);
        InitNode();
        //開始演出が終わるまでは操作を受け付けない
        SetSlideAll(true);

        // スライドベクトルの垂線を算出
        Vector3 leftUp = gameNodePrefabs[0][1].transform.position - gameNodePrefabs[0][0].transform.position;
        Vector3 leftDown = gameNodePrefabs[1][1].transform.position - gameNodePrefabs[0][0].transform.position;
        Matrix4x4 mtx = Matrix4x4.identity;
        mtx.SetTRS(new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Euler(0.0f, 0.0f, 90.0f), new Vector3(1.0f, 1.0f, 1.0f));
        leftUp = mtx.MultiplyVector(leftUp).normalized;
        leftDown = mtx.MultiplyVector(leftDown).normalized;
        slideLeftUpPerNorm = new Vector2(leftUp.x, leftUp.y);
        slideLeftDownPerNorm = new Vector2(leftDown.x, leftDown.y);

        // SE準備
        cumSlideIntervalPlaySE = 0.0f;

        // ----- インプット処理
        Observable
            .EveryUpdate()
            .Where(_ => Input.GetMouseButton(0))
            .Subscribe(_ => {
                // タップに成功していなければ未処理
                if (!isTap)
                {
                    return;
                }
                Vector3 worldTapPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                // スライド処理
                if (isSlide)
                {
                    prevTapPos = tapPos;
                    tapPos = new Vector2(worldTapPos.x, worldTapPos.y);

                    SlideNodes();
                    CheckSlideOutLimitNode();
                    LoopBackNode();

                    return;
                }

                // スライド判定
                if (tapNodeID.x > -1 && startTapPos != (Vector2)worldTapPos)
                {
                    _eSlideDir dir = CheckSlideDir(startTapPos, new Vector2(worldTapPos.x, worldTapPos.y));
                    Vec2Int nextNodeID = GetDirNode(tapNodeID, dir);
                    if (nextNodeID.x > -1)
                    {
                        if (Vector3.Distance(gameNodePrefabs[tapNodeID.y][tapNodeID.x].transform.position, worldTapPos) >
                            Vector3.Distance(gameNodePrefabs[nextNodeID.y][nextNodeID.x].transform.position, worldTapPos))
                        {
                            isSlide = true;
                            _isNodeAction = true;
                            StartSlideNodes(nextNodeID, dir);
                        }
                    }
                }
            })
            .AddTo(this.gameObject);
        Observable
            .EveryUpdate()
            .Where(_ => Input.GetMouseButtonDown(0))
            .Subscribe(_ => {
                // スライド中なら未処理
                if (isSlide)
                    return;
                if (pauseScript.pauseState == _ePauseState.PAUSE)
                    return;

                if (levelControllerScript.LevelState != _eLevelState.STAND)
                    return;

                // タップ成功
                isTap = true;
                ////Log.Debug("MouseButtonDown");

                Vector3 worldTapPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                startTapPos = new Vector2(worldTapPos.x, worldTapPos.y);

                // タップしているノードのIDを検索
                tapNodeID = SearchNearNodeRemoveFrame(worldTapPos);
            })
            .AddTo(this.gameObject);
        Observable
            .EveryUpdate()
            .Where(_ => Input.GetMouseButtonUp(0))
            .Subscribe(_ => TapRelease()/*{
                // タップに成功していなければ未処理
                if (!isTap)
                    return;

                // タップ終了
                isTap = false;
                //Log.Debug("MouseButtonUp");

                if (isSlide)
                {
                    AdjustNodeStop();
                    isSlideEnd = true;
                    tapNodeID = Vec2Int.zero;
                }
                else {
                    if (tapNodeID.x > -1)
                    {
                        audioSources[(int)_eAudioNumber.ROTATE].Play();
                        gameNodeScripts[tapNodeID.y][tapNodeID.x].RotationNode();
                        _isNodeAction = true;
                    }
                }
            }*/)
            .AddTo(gameObject);

        // ノードのアニメーション終了と同時に接続チェック
        Observable
            .EveryUpdate()
            .Select(x =>  !(IsNodeAction) && !(isNodeLock))
            .DistinctUntilChanged()
            .Where(x => x)
            .ThrottleFrame(3)
            .Subscribe(x => {
                CheckLink();
            })
            .AddTo(gameObject);

        // ノードがアクション中かチェック
        Observable
            .EveryUpdate()
            .Where(_ => _isNodeAction)
            .Subscribe(_ => {
                for (int i = 0; i < col; ++i)
                {
                    foreach (var nodes in gameNodeScripts[i])
                    {
                        if (nodes.IsAction)
                            return;
                    }
                }
                _isNodeAction = false;
            })
            .AddTo(gameObject);

        // ノードがスライド終了処理中かチェック
        Observable
            .EveryUpdate()
            .Where(_ => isSlideEnd)
            .Subscribe(_ => {
                for (int i = 0; i < col; ++i)
                {
                    foreach (var nodes in gameNodeScripts[i])
                    {
                        if (nodes.IsSlideEnd)
                        {
                            return;
                        }
                    }
                }
                isSlideEnd = false;
                if (isSlide)
                {
                    isSlide = false;
                    slideDir = _eSlideDir.NONE;

                    cumSlideIntervalPlaySE = 0.0f;
                }
            })
            .AddTo(gameObject);

        // SE再生処理
        Observable
            .EveryUpdate()
            .Where(_ => isSlide)
            .Subscribe(_ => {
                if(cumSlideIntervalPlaySE > slideIntervalPlaySE) {
                    audioSources[(int)_eAudioNumber.SLIDE].Play();

                    cumSlideIntervalPlaySE = 0.0f;
                }
            })
            .AddTo(gameObject);

        Observable
            .NextFrame()
            .Subscribe(_ => CheckLink(true, true))
            .AddTo(this);
    }