Inheritance: GameObject
Beispiel #1
0
 //For moves-before-bording only
 public QueuedCommand(Ship s, Hex3D h, int offset)
 {
     agent = s;
     targetHex = h;
     order = Command.Action.Move;
     shiptype = null;
     priority = 50 + offset;
 }
Beispiel #2
0
 public QueuedCommand(Command C, Galaxy g, int offset)
 {
     agent = (Unit)g.GetHex(C.start).GetGameObject();
     try
     {
         targetHex = g.GetHex(C.target);
     }
     catch (NullReferenceException) {
         targetHex = null;
     }
     order = C.action;
     shiptype = C.shiptype;
     priority = 10*(int)order+offset;
 }
Beispiel #3
0
        public void Attack(Unit u)
        {
            double x = u.getCenter().X - hex.getCenter().X;
            double y = hex.getCenter().Y - u.getCenter().Y;
            targetangle = Math.Atan(x / y);
            if (y < 0) targetangle = targetangle + Math.PI;

            u.hit(damage);

            firingsource = this.getCenter();
            firingpercent = 0;
            firingtarget = u.getCenter();
            firinganimation = true;
        }
Beispiel #4
0
        public void Update(Unit u)
        {
            selectedunit = u;

            //Update Health Display
            int MaxHealth = u.getMaxHealth();
            int CurHealth = u.getHealth();
            healthBar.SetGoalNumber(MaxHealth);
            healthBar.SetCurrentNumber(CurHealth);

            nameline.text = u.GetType().Name;
            healthline.text = "Health:    " + CurHealth + "/" + MaxHealth;

            //build display
            if (u is Planet)
            {
                Planet tmpPlanet = (Planet)u;
                List<Unit> upComingUnits = tmpPlanet.BuildQueue;
                if (upComingUnits.Count > 0)
                {
                    buildBar.IsVisible = true;
                    Ship tmpShip = (Ship)upComingUnits[0];
                    String shipname = tmpShip.GetShipType().modelstring;
                    int MaxBuildTime = tmpShip.GetBuildTime();
                    int nextBuildTime = tmpPlanet.BuildTimes[0];
                    buildLine.text = "Build Time:  " + nextBuildTime + "/" + MaxBuildTime + "  -> " + shipname;
                    //Any more ships queued up?

                    upComingLine.text = "";
                    if (upComingUnits.Count > 1)
                    {
                        upComingLine.text = "Next : ";
                        for(int i = 1; i < upComingUnits.Count; i++){
                            Ship nextShip = (Ship) upComingUnits[i];
                            upComingLine.text += "[" + nextShip.shiptype.modelstring.Substring(0, 6) + "]";
                        }
                    }

                    buildBar.SetGoalNumber(MaxBuildTime);
                    buildBar.SetCurrentNumber(nextBuildTime);
                }
                else
                {
                    buildLine.text = "No Ships Being Built";
                    buildBar.IsVisible = false;
                }
            }
            else if (u is Carrier)
            {
                upComingLine.text = "Carrying: " + ((Carrier)u).GetLoad();
                buildLine.text = "";
                buildBar.IsVisible = false;
            }
            else
            {
                upComingLine.text = "";
                buildLine.text = "";
                buildBar.IsVisible = false;
            }
        }