Example #1
0
 private void SetObjectInfo(SymbolTable symbolTable)
 {
     symbolTable.set("x", x);
     symbolTable.set("y", y);
     symbolTable.set("vx", vx);
     symbolTable.set("vy", vy);
     //symbolTable.set("hp", HP);
 }
Example #2
0
        public double generate(SymbolTable table)
        {
            table.ClearUnnecessary();
            double st = table.get("gt");

            if (startTime == -1)
            {
                startTime = st;
                st        = 0;
            }
            else
            {
                st -= startTime;
            }
            table.set("t", st);

            int ret = 1;

            foreach (Exp exp in preExp)
            {
                exp.generate(table);
            }
            foreach (Script_Block sb in script_block)
            {
                if (sb.generate(table) == -1)
                {
                    ret = -1;
                }
            }
            return(ret);
        }
Example #3
0
        public override double generate(SymbolTable table)
        {
            double l = left.generate(table);
            double r = right.generate(table);

            switch (ope)
            {
            case Exp_Operator.DIVI:
                if (r == 0)
                {
                    return(0);
                }
                return(l / r);

            case Exp_Operator.MINU:
                return(l - r);

            case Exp_Operator.MULT:
                return(l * r);

            case Exp_Operator.PLUS:
                return(l + r);

            case Exp_Operator.EQUAL:
                table.set(left.getID(), r);
                return(r);

            case Exp_Operator.LESS_THAN:
                return(l < r ? 1 : 0);

            case Exp_Operator.GREATER_THAN:
                return(l > r ? 1 : 0);

            case Exp_Operator.IF_EQUAL:
                return(l == r ? 1 : 0);

            case Exp_Operator.NOT_EQUAL:
                return(l != r ? 1 : 0);

            case Exp_Operator.LESS_EQUAL_THAN:
                return(l <= r ? 1 : 0);

            case Exp_Operator.GREATER_EQUAL_THAN:
                return(l >= r ? 1 : 0);

            default:
                LogWriter.WriteErrText("Unknown double operator " + ope.ToString());
                break;
            }
            return(0);
        }
Example #4
0
 public double generate(SymbolTable table)
 {
     table.set("destroy", 1);
     return(0);
 }
Example #5
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);
        }