コード例 #1
0
 public void PlaySound(string name, int vol)
 {
     if (paused)
     {
         return;
     }
     if (sounds.ContainsKey(name))
     {
         AudioEffect ass = ((AudioEffect)sounds.Get(name));
         ass.AudioEffectVolume(vol);
         ass.PlayAudioEffect();
     }
     else
     {
         if (clipCount > 50)
         {
             int         idx  = sounds.Size() - 1;
             string      k    = (string)sounds.GetKey(idx);
             AudioEffect clip = (AudioEffect)sounds.Remove(k);
             clip.StopAudioEffect();
             clip = null;
             clipCount--;
         }
         asound = new AudioEffect(name);
         asound.AudioEffectVolume(vol);
         asound.PlayAudioEffect();
         sounds.Put(name, asound);
         clipCount++;
     }
 }
コード例 #2
0
ファイル: SpriteBatchScreen.cs プロジェクト: vb0067/LGame
        public void ReleaseActionKeys()
        {
            int size = keyActions.Size();

            if (size > 0)
            {
                for (int i = 0; i < size; i++)
                {
                    ActionKey act = (ActionKey)keyActions.Get(i);
                    act.Release();
                }
            }
        }
コード例 #3
0
ファイル: JSONObject.cs プロジェクト: zx8326123/LGame
        public override string ToString()
        {
            StringBuilder buf = new StringBuilder();

            buf.Append("{");
            bool first = true;

            for (int i = 0; i < _map.Size(); i++)
            {
                object value_ren = _map.Get(i);
                if (!first)
                {
                    buf.Append(",");
                }
                first = false;
                buf.Append("\"").Append(_map.GetKey(i)).Append("\"").Append(":");
                if (value_ren   is  string)
                {
                    buf.Append("\"").Append(value_ren.ToString()).Append("\"");
                }
                else
                {
                    buf.Append(value_ren.ToString());
                }
            }
            buf.Append("}");
            return(buf.ToString());
        }
コード例 #4
0
 public int PutImage(string name, LImage image)
 {
     CheckPacked();
     if (image == null)
     {
         throw new NullReferenceException();
     }
     if (image.GetWidth() <= 0 || image.GetHeight() <= 0)
     {
         throw new ArgumentException(
                   "width and height must be positive");
     }
     this.temps.Put(name, new PackEntry(image));
     this.packing = true;
     this.count++;
     return(temps.Size() - 1);
 }
コード例 #5
0
        public string DoExecute()
        {
            if (isClose)
            {
                return(null);
            }
            this.executeCommand = null;
            this.addCommand     = true;
            this.isInnerCommand = (innerCommand != null);
            this.if_bool        = false;
            this.elseif_bool    = false;

            try
            {
                if (isInnerCommand && isCall)
                {
                    SetVariables(innerCommand.GetVariables());
                    if (innerCommand.Next())
                    {
                        return(innerCommand.DoExecute());
                    }
                    else
                    {
                        InnerCallFalse();
                        return(executeCommand);
                    }
                }
                else if (isInnerCommand && !isCall)
                {
                    SetVariables(innerCommand.GetVariables());
                    if (innerCommand.Next())
                    {
                        return(innerCommand.DoExecute());
                    }
                    else
                    {
                        innerCommand   = null;
                        isInnerCommand = false;
                        return(executeCommand);
                    }
                }

                nowPosFlagName = offsetPos.ToString();
                int length = conditionEnvironmentList.Size();
                if (length > 0)
                {
                    object ifResult = conditionEnvironmentList.Get(length - 1);
                    if (ifResult != null)
                    {
                        backIfBool = (bool)(((Boolean)ifResult));
                    }
                }

                if (scriptList == null)
                {
                    ResetCache();
                    return(executeCommand);
                }
                else if (scriptList.Length - 1 < offsetPos)
                {
                    ResetCache();
                    return(executeCommand);
                }

                string cmd = scriptList[offsetPos];

                if (cmd.StartsWith(RESET_CACHE_TAG))
                {
                    ResetCache();
                    return(executeCommand);
                }

                if (isCache)
                {
                    cacheCommandName = NowCacheOffsetName(cmd);

                    object cache = CollectionUtils.Get(scriptContext, cacheCommandName);
                    if (cache != null)
                    {
                        return((string)cache);
                    }
                }

                if (flaging)
                {
                    flaging = !(cmd.StartsWith(FLAG_LS_E_TAG) || cmd
                                .EndsWith(FLAG_LS_E_TAG));
                    return(executeCommand);
                }

                if (!flaging)
                {
                    if (cmd.StartsWith(FLAG_LS_B_TAG) &&
                        !cmd.EndsWith(FLAG_LS_E_TAG))
                    {
                        flaging = true;
                        return(executeCommand);
                    }
                    else if (cmd.StartsWith(FLAG_LS_B_TAG) &&
                             cmd.EndsWith(FLAG_LS_E_TAG))
                    {
                        return(executeCommand);
                    }
                }

                SetupRandom(cmd);

                SetupSET(cmd);

                if (cmd.EndsWith(END_TAG))
                {
                    functioning = false;
                    return(executeCommand);
                }

                if (cmd.StartsWith(BEGIN_TAG))
                {
                    temps = CommandSplit(cmd);
                    if (temps.Count == 2)
                    {
                        functioning = true;
                        functions.Put(temps[1], new string[0]);
                        return(executeCommand);
                    }
                }

                if (functioning)
                {
                    int      size     = functions.Size() - 1;
                    string[] function = (string[])functions.Get(size);
                    int      index    = function.Length;
                    function        = (string[])CollectionUtils.Expand(function, 1);
                    function[index] = cmd;
                    functions.Set(size, function);
                    return(executeCommand);
                }

                if (((!esleflag && !ifing) || (esleflag && ifing)) &&
                    cmd.StartsWith(CALL_TAG) && !isCall)
                {
                    temps = CommandSplit(cmd);
                    if (temps.Count == 2)
                    {
                        string   functionName = (string)temps[1];
                        string[] funs         = (string[])functions.Get(functionName);
                        if (funs != null)
                        {
                            innerCommand = new Command(scriptName + FLAG
                                                       + functionName, funs);
                            innerCommand.CloseCache();
                            innerCommand.SetVariables(GetVariables());
                            InnerCallTrue();
                            return(null);
                        }
                    }
                }

                if (!if_bool && !elseif_bool)
                {
                    if_bool     = cmd.StartsWith(IF_TAG);
                    elseif_bool = cmd.StartsWith(ELSE_TAG);
                }

                if (if_bool)
                {
                    esleover = esleflag = SetupIF(cmd, nowPosFlagName,
                                                  setEnvironmentList, conditionEnvironmentList);
                    addCommand = false;
                    ifing      = true;
                }
                else if (elseif_bool)
                {
                    string[] value_ren = StringUtils.Split(cmd, " ");
                    if (!backIfBool && !esleflag)
                    {
                        if (value_ren.Length > 1 && IF_TAG.Equals(value_ren[1]))
                        {
                            esleover = esleflag = SetupIF(
                                cmd.Replace(ELSE_TAG, "").Trim(),
                                nowPosFlagName, setEnvironmentList,
                                conditionEnvironmentList);
                            addCommand = false;
                        }
                        else if (value_ren.Length == 1 && ELSE_TAG.Equals(value_ren[0]))
                        {
                            if (!esleover)
                            {
                                esleover = esleflag = SetupIF("if 1==1",
                                                              nowPosFlagName, setEnvironmentList,
                                                              conditionEnvironmentList);
                                addCommand = false;
                            }
                        }
                    }
                    else
                    {
                        esleflag   = false;
                        addCommand = false;
                        conditionEnvironmentList.Put(nowPosFlagName, (bool)(false));
                    }
                }

                if (cmd.StartsWith(IF_END_TAG))
                {
                    conditionEnvironmentList.Clear();
                    backIfBool  = false;
                    addCommand  = false;
                    ifing       = false;
                    if_bool     = false;
                    elseif_bool = false;
                    esleover    = false;
                    return(null);
                }
                if (backIfBool)
                {
                    if (cmd.StartsWith(INCLUDE_TAG))
                    {
                        if (IncludeCommand(cmd))
                        {
                            return(null);
                        }
                    }
                }
                else if (cmd.StartsWith(INCLUDE_TAG) && !ifing && !backIfBool &&
                         !esleflag)
                {
                    if (IncludeCommand(cmd))
                    {
                        return(null);
                    }
                }

                if (cmd.StartsWith(OUT_TAG))
                {
                    isRead         = false;
                    addCommand     = false;
                    executeCommand = (SELECTS_TAG + " " + readBuffer.ToString());
                }

                if (isRead)
                {
                    readBuffer.Append(cmd);
                    readBuffer.Append(FLAG);
                    addCommand = false;
                }

                if (cmd.StartsWith(IN_TAG))
                {
                    readBuffer.Remove(0, readBuffer.Length - (0));
                    isRead = true;
                    return(executeCommand);
                }

                if (addCommand && ifing)
                {
                    if (backIfBool && esleflag)
                    {
                        executeCommand = cmd;
                    }
                }
                else if (addCommand)
                {
                    executeCommand = cmd;
                }

                if (cmd.StartsWith(FLAG_SAVE_TAG))
                {
                    temps = CommandSplit(cmd);
                    if (temps != null && temps.Count == 2)
                    {
                        executeCommand = cmd;
                        SaveCommand(null, null);
                        return(executeCommand);
                    }
                }
                else if (cmd.StartsWith(FLAG_LOAD_TAG))
                {
                    temps = CommandSplit(cmd);
                    if (temps != null && temps.Count == 2)
                    {
                        executeCommand = cmd;
                        LoadCommand(null, -1);
                        return(executeCommand);
                    }
                }

                if (executeCommand != null)
                {
                    printTags = Command.GetNameTags(executeCommand, PRINT_TAG
                                                    + BRACKET_LEFT_TAG, BRACKET_RIGHT_TAG);
                    if (printTags != null)
                    {
                        for (IEnumerator it = printTags.GetEnumerator(); it.MoveNext();)
                        {
                            string key       = (string)it.Current;
                            object value_ren = CollectionUtils.Get(setEnvironmentList, key);
                            if (value_ren != null)
                            {
                                executeCommand = StringUtils
                                                 .ReplaceMatch(
                                    executeCommand,
                                    (PRINT_TAG + BRACKET_LEFT_TAG + key + BRACKET_RIGHT_TAG)
                                    , value_ren.ToString());
                            }
                            else
                            {
                                executeCommand = StringUtils
                                                 .ReplaceMatch(
                                    executeCommand,
                                    (PRINT_TAG + BRACKET_LEFT_TAG + key + BRACKET_RIGHT_TAG)
                                    , key);
                            }
                        }
                    }

                    if (isCache)
                    {
                        CollectionUtils.Put(scriptContext, cacheCommandName, executeCommand);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                if (!isInnerCommand)
                {
                    offsetPos++;
                }
            }

            return(executeCommand);
        }
コード例 #6
0
ファイル: NSDictionary.cs プロジェクト: zx8326123/LGame
 public int Count()
 {
     return(_dict.Size());
 }
コード例 #7
0
ファイル: BMFont.cs プロジェクト: zx8326123/LGame
        private void DrawBatchString(float tx, float ty, string text, LColor c,
                                     int startIndex, int endIndex)
        {
            if (isClose)
            {
                return;
            }

            if (displays.Size() > DEFAULT_MAX_CHAR)
            {
                displays.Clear();
            }

            lazyHashCode = 1;

            if (c != null)
            {
                lazyHashCode = LSystem.Unite(lazyHashCode, c.r);
                lazyHashCode = LSystem.Unite(lazyHashCode, c.g);
                lazyHashCode = LSystem.Unite(lazyHashCode, c.b);
                lazyHashCode = LSystem.Unite(lazyHashCode, c.a);
            }

            string key = text + lazyHashCode;

            Display display = (Display)displays.Get(key);

            if (display == null)
            {
                int x = 0, y = 0;

                displayList.GLBegin();
                displayList.SetBatchPos(tx, ty);

                if (c != null)
                {
                    displayList.SetImageColor(c);
                }

                CharDef lastCharDef = null;
                char[]  data        = text.ToCharArray();
                for (int i = 0; i < data.Length; i++)
                {
                    int id = data[i];
                    if (id == '\n')
                    {
                        x  = 0;
                        y += GetLineHeight();
                        continue;
                    }
                    if (id >= chars.Length)
                    {
                        continue;
                    }
                    CharDef charDef = chars[id];
                    if (charDef == null)
                    {
                        continue;
                    }

                    if (lastCharDef != null)
                    {
                        x += lastCharDef.GetKerning(id);
                    }
                    lastCharDef = charDef;

                    if ((i >= startIndex) && (i <= endIndex))
                    {
                        charDef.Draw(x, y);
                    }

                    x += charDef.advance;
                }

                if (c != null)
                {
                    displayList.SetImageColor(LColor.white);
                }

                displayList.GLEnd();

                display = new Display();

                display.cache  = displayList.NewBatchCache();
                display.text   = text;
                display.width  = 0;
                display.height = 0;

                displays.Put(key, display);
            }
            else if (display.cache != null)
            {
                display.cache.x = tx;
                display.cache.y = ty;
                LTextureBatch.Commit(displayList, display.cache);
            }
        }
コード例 #8
0
        public virtual void PaintObjects(GLEx g, int minX, int minY, int maxX, int maxY)
        {
            lock (objects)
            {
                IIterator it = objects.Iterator();
                for (; it.HasNext();)
                {
                    thing = (Actor)it.Next();
                    if (!thing.visible)
                    {
                        continue;
                    }
                    isListener = (thing.actorListener != null);

                    if (isVSync)
                    {
                        if (isListener)
                        {
                            thing.actorListener.Update(elapsedTime);
                        }
                        thing.Update(elapsedTime);
                    }

                    RectBox rect = thing.GetRectBox();
                    actorX      = minX + thing.GetX();
                    actorY      = minY + thing.GetY();
                    actorWidth  = rect.width;
                    actorHeight = rect.height;
                    if (actorX + actorWidth < minX || actorX > maxX ||
                        actorY + actorHeight < minY || actorY > maxY)
                    {
                        continue;
                    }
                    LTexture actorImage = thing.GetImage();
                    if (actorImage != null)
                    {
                        width          = (actorImage.GetWidth() * thing.scaleX);
                        height         = (actorImage.GetHeight() * thing.scaleY);
                        isBitmapFilter = (thing.filterColor != null);
                        thing.SetLastPaintSeqNum(paintSeq++);
                        angle      = thing.GetRotation();
                        colorAlpha = thing.alpha;

                        if (thing.isAnimation)
                        {
                            if (isBitmapFilter)
                            {
                                g.DrawTexture(actorImage, actorX, actorY, width,
                                              height, angle, thing.filterColor);
                            }
                            else
                            {
                                if (colorAlpha != 1f)
                                {
                                    g.SetAlpha(colorAlpha);
                                }
                                g.DrawTexture(actorImage, actorX, actorY, width,
                                              height, angle);
                                if (colorAlpha != 1f)
                                {
                                    g.SetAlpha(1f);
                                }
                            }
                        }
                        else
                        {
                            int texId = actorImage.GetTextureID();

                            LTextureBatch batch = (LTextureBatch)textures
                                                  .GetValue(texId);

                            if (batch == null)
                            {
                                LTextureBatch pBatch = LTextureBatch
                                                       .BindBatchCache(this, texId,
                                                                       actorImage);
                                batch = pBatch;
                                batch.GLBegin();

                                textures.Put(texId, batch);
                            }

                            batch.SetTexture(actorImage);

                            if (isBitmapFilter)
                            {
                                batch.Draw(actorX, actorY, width, height, angle,
                                           thing.filterColor);
                            }
                            else
                            {
                                if (colorAlpha != 1f)
                                {
                                    alphaColor.a = colorAlpha;
                                }
                                batch.Draw(actorX, actorY, width, height, angle,
                                           alphaColor);
                                if (colorAlpha != 1f)
                                {
                                    alphaColor.a = 1;
                                }
                            }
                        }
                    }
                    if (thing.isConsumerDrawing)
                    {
                        if (actorX == 0 && actorY == 0)
                        {
                            thing.Draw(g);
                            if (isListener)
                            {
                                thing.actorListener.Draw(g);
                            }
                        }
                        else
                        {
                            g.Translate(actorX, actorY);
                            thing.Draw(g);
                            if (isListener)
                            {
                                thing.actorListener.Draw(g);
                            }
                            g.Translate(-actorX, -actorY);
                        }
                    }
                }

                int size = textures.Size();
                if (size > 0)
                {
                    for (int i = 0; i < size; i++)
                    {
                        LTextureBatch batch = (LTextureBatch)textures.Get(i);
                        batch.GLEnd();
                    }
                    textures.Clear();
                }
            }
        }
コード例 #9
0
ファイル: SpriteBatchScreen.cs プロジェクト: zx8326123/LGame
 public virtual void AddActionKey(Int32 keyCode, ActionKey e)
 {
     keyActions.Put(keyCode, e);
     keySize = keyActions.Size();
 }
コード例 #10
0
 public void Paint(GLEx g)
 {
     if (background != null)
     {
         if (shakeNumber > 0)
         {
             g.DrawTexture(background,
                           shakeNumber / 2 - LSystem.random.Next(shakeNumber),
                           shakeNumber / 2 - LSystem.random.Next(shakeNumber));
         }
         else
         {
             g.DrawTexture(background, 0, 0);
         }
     }
     lock (charas)
     {
         for (int i = 0; i < charas.Size(); i++)
         {
             AVGChara chara = (AVGChara)charas.Get(i);
             if (chara == null || !chara.isVisible)
             {
                 continue;
             }
             if (style)
             {
                 if (chara.flag != -1)
                 {
                     if (chara.flag == FadeEffect.TYPE_FADE_IN)
                     {
                         chara.currentFrame--;
                         if (chara.currentFrame == 0)
                         {
                             chara.opacity = 0;
                             chara.flag    = -1;
                             chara.Dispose();
                             charas.Remove(chara);
                         }
                     }
                     else
                     {
                         chara.currentFrame++;
                         if (chara.currentFrame == chara.time)
                         {
                             chara.opacity = 0;
                             chara.flag    = -1;
                         }
                     }
                     chara.opacity = (chara.currentFrame / chara.time) * 255;
                     if (chara.opacity > 0)
                     {
                         g.SetAlpha(chara.opacity / 255);
                     }
                 }
             }
             if (chara.isAnimation)
             {
                 AVGAnm animation = chara.anm;
                 if (animation.load)
                 {
                     if (animation.loop && animation.startTime == -1)
                     {
                         animation.Start(0, loop);
                     }
                     Point.Point2i point = animation.GetPos(JavaRuntime
                                                            .CurrentTimeMillis());
                     if (animation.alpha != 1f)
                     {
                         g.SetAlpha(animation.alpha);
                     }
                     g.DrawTexture(animation.texture, chara.x, chara.y,
                                   animation.width, animation.height, point.x,
                                   point.y, point.x + animation.imageWidth,
                                   point.y + animation.imageHeight,
                                   animation.angle, animation.color);
                     if (animation.alpha != 1f)
                     {
                         g.SetAlpha(1f);
                     }
                 }
             }
             else
             {
                 chara.Next();
                 chara.draw(g);
             }
             if (style)
             {
                 if (chara.flag != -1 && chara.opacity > 0)
                 {
                     g.SetAlpha(1f);
                 }
             }
         }
     }
 }