示例#1
0
        private void MakeToungue(EntityRegistry registry, Entity parentFrog)
        {
            Entity       toungue = registry.Create();
            ToungueState state   = new ToungueState(ToungueStages.Extending, mData.GetStateTime(ToungueStages.Extending));

            registry.AddComponent(toungue, state);
            registry.AddComponent(toungue, new RectShape());
            registry.AddComponent(toungue, new Position());
            registry.AddComponent(toungue, Color.Red);
            registry.AddComponent(toungue, new ParentEntity(parentFrog, new Vector2()));

            ControlledEntity controlledToungue = new ControlledEntity(toungue);

            registry.AddComponent(parentFrog, controlledToungue);
        }
示例#2
0
        public void Update(EntityRegistry registry, EventSystem eventSystem)
        {
            int count = mTounguesWithShape.Entity.Count;

            for (int i = 0; i < count; ++i)
            {
                ToungueState currentState = mTounguesWithShape.ToungueState[i];
                switch (currentState.Stage)
                {
                case ToungueStages.Refreshing:
                default:
                    mDoneToungues.Add(mTounguesWithShape.Entity[i]);
                    break;

                case ToungueStages.Retracting:
                    float relativeStage = currentState.TimeLeft / mToungueData.GetStateTime(ToungueStages.Retracting);
                    float width         = mShapeData.Length * relativeStage;
                    registry.SetComponent(mTounguesWithShape.Entity[i], new RectShape(width, mShapeData.Thickness));
                    break;

                case ToungueStages.Extended:
                    registry.SetComponent(mTounguesWithShape.Entity[i], new RectShape(mShapeData.Length, mShapeData.Thickness));
                    break;

                case ToungueStages.Extending:
                    relativeStage = currentState.TimeLeft / mToungueData.GetStateTime(ToungueStages.Extending);
                    width         = mShapeData.Length * (1f - relativeStage);
                    registry.SetComponent(mTounguesWithShape.Entity[i], new RectShape(width, mShapeData.Thickness));
                    break;
                }
            }
            foreach (Entity toungue in mDoneToungues)
            {
                registry.RemoveComponent <RectShape>(toungue);
                registry.RemoveComponent <Position>(toungue);    //Weird to remove here?
            }
            mDoneToungues.Clear();
        }
示例#3
0
        private void UpdateToungueState(EntityRegistry registry)
        {
            int count = mAllToungues.Entity.Count;

            for (int i = 0; i < count; ++i)
            {
                ToungueState state   = mAllToungues.State[i];
                float        newTime = state.TimeLeft - mTime.DeltaTime;
                if (newTime > 0)
                {
                    state.TimeLeft = newTime;
                    registry.SetComponent(mAllToungues.Entity[i], state);
                }
                else
                {
                    int stateIndex = (int)state.Stage;
                    if (stateIndex > 0)
                    {
                        ToungueStages nextStage = (ToungueStages)(stateIndex - 1);
                        float         nextTime  = mData.GetStateTime(nextStage);
                        registry.SetComponent(mAllToungues.Entity[i], new ToungueState(nextStage, nextTime));
                    }
                    else
                    {
                        mTransitioning.Add(mAllToungues.Entity[i]);
                    }
                }
            }
            foreach (Entity toungue in mTransitioning)
            {
                Entity frog = registry.GetComponent <ParentEntity>(toungue).Parent;
                registry.RemoveComponent <ControlledEntity>(frog);
                registry.Destroy(toungue);
            }
            mTransitioning.Clear();
        }