Exemplo n.º 1
0
        public double generate(SymbolTable table)
        {
            List <Script> prototype = table.getPrototype();
            List <Script> loadList  = table.getLoadList();
            Script        scriptX   = null;

            foreach (Script script in prototype)
            {
                if (script.title.Equals(scriptName))
                {
                    scriptX = script.clone();
                    break;
                }
            }
            if (scriptX == null)
            {
                LogWriter.WriteErrText("Script Name : " + scriptName + " Unfound");
                return(0);
            }
            for (int i = 0; i < pars.Count; i++)
            {
                scriptX.preExp.Add(
                    Exp.getInstance(Exp.getInstance("arg" + i), Exp.getInstance(pars[i].generate(table)), Exp_Operator.EQUAL));
            }

            loadList.Add(scriptX);
            return(0);
        }
Exemplo n.º 2
0
        public bool OnUpdate(double deltaTime)
        {
            gameTime += deltaTime;
            symbolTable.set("gt", gameTime);
            symbolTable.set("dt", deltaTime);
            symbolTable.set("p_x", p_x);
            symbolTable.set("p_y", p_y);
            g.Clear(Color.Black);
            double x, y;
            int    ret;

            for (int i = 0; i < currentList.Count; i++)
            {
                ret = currentList[i].OnUpdate(symbolTable);
                switch (ret)
                {
                case 1:
                    friendGroup.Add(currentList[i]);
                    break;

                case 2:
                    enemyGroup.Add(currentList[i]);
                    break;

                case -1:
                    removelist.Add(currentList[i]);
                    break;
                }
                if (currentList[i].isVisible && !removelist.Contains(currentList[i]))
                {
                    if (checkBound(currentList[i]) && currentList[i].OnOutOfBound())
                    {
                        removelist.Add(currentList[i]);
                        continue;
                    }

                    x = currentList[i].x + d_x;
                    y = currentList[i].y + d_y;

                    checkCollide(currentList[i]);
                    checkLoadingImage(currentList[i]);
                    if (currentList[i].image != null)
                    {
                        drawImage((float)x, (float)y, currentList[i].image);
                    }
                    else
                    {
                        drawEllipse((float)x, (float)y, (float)currentList[i].size);
                    }

                    if (currentList[i].isPlayer)
                    {
                        drawEllipse((float)x, (float)y, (float)currentList[i].size);
                        p_x = currentList[i].x;
                        p_y = currentList[i].y;
                    }
                }
            }
            foreach (GameObject gameObject in removelist)
            {
                removeObject(gameObject);
            }
            removelist.Clear();
            foreach (GameObject gameObject in collideList)
            {
                if (gameObject.OnCollide())
                {
                    removeObject(gameObject);
                }
            }
            collideList.Clear();
            List <Script> loadlist = symbolTable.getLoadList();

            for (int i = 0; i < loadlist.Count; i++)
            {
                addObject(loadlist[i]);
            }
            loadlist.Clear();
            if (currentList.Count == 0)
            {
                OnFinished();
                initialize();
                return(true);
            }
            return(false);
        }