Ejemplo n.º 1
0
        UCompositeGameObject AddTank(string[] picList, GOParams[] par)
        {
            UCompositeGameObject tank = new UCompositeGameObject(par[0].X, par[0].Y, picList[0]);

            Map.ContainerSetMaxSide(tank.Container, (int)par[0].Par["maxSide"]);
            tank.AddChild(0, 0, 0, picList[1]);

            Map.ContainerSetMaxSide(tank.Children[0].Container, (int)par[1].Par["maxSide"]);
            return(tank);
        }
Ejemplo n.º 2
0
        public override void Init(params object[] par)
        {
            CompositeUnit = (UCompositeGameObject)unit;
            SquareRadius  = CompositeUnit.Children[0].Par.Range * CompositeUnit.Children[0].Par.Range;
            UGameObjectBase tempTarget   = null;
            double          tempMinAngle = 360;
            double          a;
            double          r;
            double          MinRange = 9999999999;
            //temp out the range target
            UGameObjectBase tempOTRTarget = null;

            //поиск цели в радиусе поражения
            for (int i = 0; i < targetList.Count; i++)
            {
                r = (targetList[i].Par.X - unit.Par.X) * (targetList[i].Par.X - unit.Par.X) + (targetList[i].Par.Y - unit.Par.Y) * (targetList[i].Par.Y - unit.Par.Y);
                if (r < SquareRadius)
                {
                    a = GameMath.CompareAngles(unit.Par.Angle, GameMath.GetAngleOfVector(targetList[i].Par.X - unit.Par.X, targetList[i].Par.Y - unit.Par.Y));
                    if (a < tempMinAngle)
                    {
                        tempMinAngle = a;
                        tempTarget   = targetList[i];
                    }
                }
                else
                {
                    if (r < MinRange)
                    {
                        MinRange      = r;
                        tempOTRTarget = targetList[i];
                    }
                }
            }
            //поиск цели вне радиуса при необходимости
            RemoveAllBehaviorsExceptAI();

            if (tempTarget != null)
            {
                // if (currTarget != tempTarget)

                currStatus = 1;
                currTarget = tempTarget;
                CompositeUnit.Children[0].AddBehavior(new ShootWhenAimed(currTarget, "LightShell", targetList), "ShootWhenAimed");
            }
            else
            {
                currStatus = 3;
                currTarget = tempOTRTarget;
                unit.AddBehavior(new MoveForward(), "MoveForward");
                //что если tempOTRTarget=null?
            }
            unit.AddBehavior(new RotateTo(currTarget, 1), "RotateTo");
            CompositeUnit.Children[0].AddBehavior(new RotateTo(currTarget, 1), "RotateTo");
        }
Ejemplo n.º 3
0
        public void Destroyed()
        {
            game.Map.ContainerSetFrame(Container, destroyedPictureName);
            game.Map.ContainerSetMaxSide(Container, 60);
            UCompositeGameObject c = this as UCompositeGameObject;

            if (c != null)
            {
                for (int j = 0; j < c.Children.Count; j++)
                {
                    c.Children[j].removeObject();
                }
            }
        }
Ejemplo n.º 4
0
 public void RightClick()
 {
     if (game.ClickedObj != null)
     {
         UCompositeGameObject o = (UCompositeGameObject)game.ClickedObj;
         for (int i = 0; i < o.Children.Count; i++)
         {
             o.Children[i].RemoveBehavior("SelectNearestByAngle");
             o.Children[i].RemoveBehavior("RotateTo");
             o.Children[i].RemoveBehavior("ShootWhenAimed");
             o.Children[i].AddBehavior(new RotateTo(this.Par, 1), "RotateTo");
             o.Children[i].AddBehavior(new ShootWhenAimed(this, o.Children[i].Par.ParString["ShellName"], game.enemies), "ShootWhenAimed");
         }
     }
 }
Ejemplo n.º 5
0
        public void StartDestroy()
        {
            game.Map.ContainerSetFrame(this.Container, "exp9");
            game.Map.AnimationStart(this.Container, "explosion", 1, this.Destroyed);
            this.RemoveAllBehaviors();
            UCompositeGameObject c = this as UCompositeGameObject;

            if (c != null)
            {
                for (int j = 0; j < c.Children.Count; j++)
                {
                    c.Children[j].RemoveAllBehaviors();
                    c.Children[j].SetContainerSize(0, 0);
                }
            }
        }
Ejemplo n.º 6
0
        UCompositeGameObject AddBaneBlade(string[] picList, GOParams[] par)
        {
            UCompositeGameObject tank = new UCompositeGameObject(par[0].X, par[0].Y, picList[0]);

            Map.ContainerSetMaxSide(tank.Container, (int)par[0].Par["maxSide"]);

            tank.AddChild(50, 40, 0, picList[1]);
            tank.AddChild(50, -40, 0, picList[1]);
            tank.AddChild(-50, 40, 0, picList[1]);
            tank.AddChild(-50, -40, 0, picList[1]);
            tank.AddChild(0, 0, 0, picList[2]);
            for (int i = 0; i < 5; i++)
            {
                Map.ContainerSetMaxSide(tank.Children[i].Container, (int)par[i + 1].Par["maxSide"]);
            }


            return(tank);
        }