示例#1
0
文件: CPU.cs 项目: furaga/Rittai3rd
        void cpuInput(GameTime gameTime)
        {
            cpuTime += gameTime.ElapsedGameTime;

            if (player.id == 0) enemy = scene.Character2P;
            if (player.id == 1) enemy = scene.Character1P;

            CPUInputState state = new CPUInputState();

            Vector2 myPos = RecVisible.Center;
            Vector2 hisPos = enemy.RecVisible.Center;
            Vector2 v = -myPos + hisPos;

            if (myPos.X < cpuMinX)
            {
                state.stick.X = 1;
                if (jumpFlg <= 0)
                {
                    state.stick.Y = 1;
                    state.button[(int)BUTTON.LB] = true;
                }
                else
                {
                    if (CheckFloat(gameTime) && velocity.Y < 0)
                    {
                        state.stick.Y = 1;
                        state.button[(int)BUTTON.LB] = true;
                    }
                }
            }
            else if (myPos.X > cpuMaxX)
            {
                state.stick.X = -1;
                if (jumpFlg <= 0)
                {
                    state.stick.Y = 1;
                    state.button[(int)BUTTON.LB] = true;
                }
                else
                {
                    if (CheckFloat(gameTime) && velocity.Y < 0)
                    {
                        state.stick.Y = 1;
                        state.button[(int)BUTTON.LB] = true;
                    }
                }
            }
            else
            {
                if (v.X > 0)
                {
                    state.stick.X = 1;
                }
                else
                {
                    state.stick.X = -1;
                }

                if (v.Y > 0.5)
                {
                    if (jumpFlg <= 0)
                    {
                        state.stick.Y = 1;
                        state.button[(int)BUTTON.LB] = true;
                    }
                    else
                    {
                        if (CheckFloat(gameTime) && velocity.Y < 0)
                        {
                            state.stick.Y = 1;
                            state.button[(int)BUTTON.LB] = true;
                        }
                    }
                }
            }

            if (v.Length() < 2.0f || cpuTime >= TimeSpan.FromSeconds(cpuNextTime))
            {
                if (cpuNextTime >= 2.0 && input.PrevCPU.button[(int)BUTTON.B] == false)
                {
                    state.button[(int)BUTTON.B] = true;
                }
                else if (input.PrevCPU.button[(int)BUTTON.A] == false)
                {
                    state.button[(int)BUTTON.A] = true;
                }
                cpuTime = TimeSpan.Zero;
                cpuNextTime = rand.NextDouble() * 3;
            }

            input.CurCPU = state;
        }
示例#2
0
        public void Initialize()
        {
            Object o;
            minSize = double.Parse((o = parameters["minSize"]) != null ? (string)o : "0.2");
            maxSize = double.Parse((o = parameters["maxSize"]) != null ? (string)o : "0.2");
            double expandTime = double.Parse((o = parameters["expandTime"]) != null ? (string)o : "0.2");
            expandSpeed = (maxSize - minSize) / expandTime;
            double explosionTime = double.Parse((o = parameters["explosionTime"]) != null ? (string)o : "0.2");
            minColor = new Vector3(
                float.Parse((o = parameters["minColorX"]) != null ? (string)o : "1"),
                float.Parse((o = parameters["minColorY"]) != null ? (string)o : "1"),
                float.Parse((o = parameters["minColorZ"]) != null ? (string)o : "1")
                );
            maxColor = new Vector3(
               float.Parse((o = parameters["maxColorX"]) != null ? (string)o : "1"),
               float.Parse((o = parameters["maxColorY"]) != null ? (string)o : "1"),
               float.Parse((o = parameters["maxColorZ"]) != null ? (string)o : "1")
               );
            dColor = new Vector3(
                (float)((maxColor.X - minColor.X) / explosionTime),
                (float)((maxColor.Y - minColor.Y) / explosionTime),
                (float)((maxColor.Z - minColor.Z) / explosionTime)
                );
            color = minColor;
            power = double.Parse((o = parameters["attackPower"]) != null ? (string)o : "0.2");
            damage = double.Parse((o = parameters["attackDamage"]) != null ? (string)o : "0.2");

            velocity = Vector2.Zero;
            speed = double.Parse((o = parameters["speed"]) != null ? (string)o : "5");
            time = TimeSpan.Zero;

            MakeModel("");

            double ex = minSize / rect.Width;
            double ey = minSize / rect.Height;
            RectangleD.ExtendRect(rect, ex, ey, RecVisible);
            Depth = RecVisible.Width;
            RecCollision = RecVisible;

            attackMinSizeX = double.Parse((o = parameters["attackMinSizeX"]) != null ? (string)o : "1");
            attackMinSizeY = double.Parse((o = parameters["attackMinSizeY"]) != null ? (string)o : "1");
            attackMaxSizeX = double.Parse((o = parameters["attackMaxSizeX"]) != null ? (string)o : "1");
            attackMaxSizeY = double.Parse((o = parameters["attackMaxSizeY"]) != null ? (string)o : "1");
            attackTime = double.Parse((o = parameters["attackTime"]) != null ? (string)o : "1");
            attackExpandSpeedX = (attackMaxSizeX - attackMinSizeX) / attackTime;
            attackExpandSpeedY = (attackMaxSizeY - attackMinSizeY) / attackTime;

            EmissiveColor = minColor;

            // 自分を追尾するAttakAreaをつくる
            o = scene.Parameters["AttackArea"];
            if (o != null)
            {
                attackArea = new AttackArea(scene, (Hashtable)o, RectangleD.ExtendRect(RecVisible, 1, 1));
                attackArea.NotAttack(owner);
                attackArea.Power = power;
                attackArea.Damage = damage;
                scene.EntityList.Add(attackArea);
                scene.AttackerList.Add(attackArea);
            }

            if (owner != 0) target1 = scene.Character1P;
            if (owner != 1) target1 = scene.Character2P;

            stopTime = double.Parse((o = parameters["stopTime"]) != null ? (string)o : "0");
        }
示例#3
0
文件: CPU.cs 项目: furaga/Rittai3rd
        void InitializeCPU()
        {
            cpuTime = TimeSpan.Zero;
            enemy = null;
            rand = new Random((int)(DateTime.Now.Ticks));
            cpuNextTime = rand.NextDouble() * 3;

            Object o = scene.Parameters[scene.Stage];
            if (o != null)
            {
                Hashtable ht = (Hashtable)o;
                Object o1;
                cpuMinX = double.Parse((o1 = ht["cpuMinX"]) != null ? (string)o1 : "-10");
                cpuMaxX = double.Parse((o1 = ht["cpuMaxX"]) != null ? (string)o1 : "10");
            }
        }