Inheritance: MonoBehaviour
示例#1
1
        public override void Create()
        {
            base.Create();

            cControl = new XboxController(SlimDX.XInput.UserIndex.One);
            pControl = new XboxController(SlimDX.XInput.UserIndex.Two);

            GameObject cursor = new Cursor(cControl);
            GameObject player = new Player(pControl);
            GameObject cannon1 = new Cannon();
            cannon1.Position.X = 365;
            cannon1.Position.Y = -265;
            GameObject cannon2 = new Cannon();
            cannon2.Position.X = 365;
            cannon2.Position.Y = 265;
            GameObject cannon3 = new Cannon();
            cannon3.Position.X = -365;
            cannon3.Position.Y = 265;
            GameObject cannon4 = new Cannon();
            cannon4.Position.X = -365;
            cannon4.Position.Y = -265;
            ObjectManager.AddGameObject(cursor);
            ObjectManager.AddGameObject(player);
            ObjectManager.AddGameObject(cannon1);
            ObjectManager.AddGameObject(cannon2);
            ObjectManager.AddGameObject(cannon3);
            ObjectManager.AddGameObject(cannon4);
        }
示例#2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Powerup")
     {
         Powerup powerup = other.attachedRigidbody.GetComponent<Powerup>();
         switch(powerup.Type)
         {
             case Powerup.Types.RapidFire:
             {
                 m_singleShot.Config = m_singleShotRapidFireConfig;
                 m_tripleShot.Config = m_tripleShotRapidFireConfig;
                 break;
             }
             case Powerup.Types.TripleShot:
             {
                 m_cannon = m_tripleShot;
                 break;
             }
             default:
                 break;
         }
     }
     else
     {
         m_health.Die();
     }
 }
示例#3
0
 void Awake()
 {
     if (CanonToUnactive == null)
     {
         CanonToUnactive = gameObject.GetComponent<Cannon>();
     }
 }
 void Awake()
 {
     cam = this.GetComponent<Camera>();
     if (m_cannonObj != null)
     {
         m_cannon = m_cannonObj.GetComponent<Cannon>();
     }
 }
示例#5
0
 void Awake()
 {
     m_multicollider = GetComponent<Multicollider>();
     m_health = GetComponent<Health>();
     m_movement = GetComponent<Movement>();
     m_singleShot = GetComponentInChildren<SingleShot>();
     m_tripleShot = GetComponentInChildren<TripleShot>();
     m_cannon = m_singleShot;
 }
示例#6
0
    protected override void Awake()
    {
        Instance = this;

        base.Awake ();
        m_renderer = GetComponentInChildren<SpriteRenderer> ();
        m_audioSource = GetComponent<AudioSource> ();

        StartCoroutine (Spawn ());
    }
示例#7
0
    void Awake()
    {
        m_health = GetComponent<Health>();
        m_movement = GetComponent<Movement>();
        m_cannon = GetComponentInChildren<Cannon>();
        m_multiCollider = GetComponent<Multicollider>();

        m_health.Died += Died;

        ZDrive.Instance.Switching += Switching;
        ZDrive.Instance.Switched += Switched;
    }
示例#8
0
    private static float GearRatio(Cannon cannon, Axis axis)
    {
        switch (axis)
        {
        case Axis.X:
            return(1 / cannon.gearRatioElevation);

        case Axis.Y:
            return(1 / cannon.gearRatioAzimuth);

        default:
            return(1);
        }
    }
示例#9
0
        public void Given_ASetupCannonThatShouldHitTheTarget_When_Shooting_Then_TheShotShouldHit()
        {
            var cannon = Cannon.GetInstance();

            cannon.TargetDistance = 1000;

            var attempt = new CannonShotAttempt(45, 100);

            var result = cannon.Shoot(attempt);

            Assert.IsTrue(result.Hit);
            Assert.AreEqual(attempt, result.Attempt);
            Assert.AreEqual(cannon.TargetDistance, result.TargetDistance);
        }
示例#10
0
        public AimAssistance(Game Game, Cannon SourceObject)
            : base(Game)
        {
            this.SourceObject = SourceObject;

            if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL)
            {
                Colour     = new Color(0, 0, 0, 192);
                Thickness  = 3;
                FillColour = new Color(255, 255, 255, 25);
            }
            else if (Game.GraphicsMode == Game.GRAPHICSMODE_BLUEPRINT)
            {
                Colour     = new Color(255, 255, 255, 255);
                Thickness  = 1;
                FillColour = new Color(255, 255, 255, 15);
            }


            // Reticle
            Reticle         = new DisplayObject();
            Reticle.Visible = false;
            AddChild(Reticle);

            UpdateReticle();

            // Aiming Lines
            LineCenter           = new RectangleShape(new Vector2f(Utils.Distance(new Vector2f(0, 48), new Vector2f(0, Game.Size.X - 48)), Thickness));
            LineCenter.FillColor = Colour;
            LineCenter.Origin    = new Vector2f(0, Thickness / 2);
            LineCenter.Position  = new Vector2f(0, 48);
            LineCenter.Rotation  = 90;
            AddChild(LineCenter);

            LineLeft           = new RectangleShape(new Vector2f(10, Thickness));
            LineLeft.FillColor = Colour;
            LineLeft.Origin    = new Vector2f(0, Thickness / 2);
            LineLeft.Position  = new Vector2f(11, 43);
            AddChild(LineLeft);

            LineRight           = new RectangleShape(new Vector2f(10, Thickness));
            LineRight.FillColor = Colour;
            LineRight.Origin    = new Vector2f(0, Thickness / 2);
            LineRight.Position  = new Vector2f(-11, 43);
            AddChild(LineRight);

            Fill           = new ConvexShape(4);
            Fill.FillColor = FillColour;
            AddChild(Fill);
        }
示例#11
0
 public RelayKIController(GDGameScreen owner, Cannon cannon, Fraction fraction)
     : base(RELAY_UPDATE_TIME, owner, cannon, fraction, 0f)
 {
     if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_RAYTRACE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreateRaycast("SupportCannon", FindTargetSupportCannon),
             KIMethod.CreateRaycast("NeutralCannon", FindTargetNeutralCannon),
             KIMethod.CreateRaycast("EnemyCannon", FindTargetEnemyCannon),
             KIMethod.CreateRaycast("RelayChain", FindTargetRelayChain),
             KIMethod.CreateRaycast("FriendlyCannon", FindTargetFriendlyCannon),
             KIMethod.CreateRaycast("BlockedEnemyCannon", FindTargetBlockedEnemyCannon),
             KIMethod.CreateRaycast("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannon),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRECALC)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("NeutralCannon", FindTargetNeutralCannonPrecalc),
             KIMethod.CreatePrecalc("EnemyCannon", FindTargetEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("RelayChain", FindTargetRelayChainPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedEnemyCannon", FindTargetBlockedEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else if (owner.Blueprint.KIType == LevelBlueprint.KI_TYPE_PRESIMULATE)
     {
         intelligence = new List <KIMethod>
         {
             KIMethod.CreatePrecalc("SupportCannon", FindTargetSupportCannonPrecalc),
             KIMethod.CreatePrecalc("NeutralCannon", FindTargetNeutralCannonPrecalc),
             KIMethod.CreatePrecalc("EnemyCannon", FindTargetEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("RelayChain", FindTargetRelayChainPrecalc),
             KIMethod.CreatePrecalc("FriendlyCannon", FindTargetFriendlyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedEnemyCannon", FindTargetBlockedEnemyCannonPrecalc),
             KIMethod.CreatePrecalc("BlockedFriendlyCannon", FindTargetBlockedFriendlyCannonPrecalc),
             KIMethod.CreateRaycast("NearestEnemyCannon", FindNearestEnemyCannon),
         };
     }
     else
     {
         throw new Exception("Unknown KIType: " + owner.Blueprint.KIType);
     }
 }
示例#12
0
    void SpawnCannon(float xOffset, float yOffset, float zOffset, string direction, float speed)
    {
        GameObject Cannon;

        Cannon = Instantiate(Resources.Load("cannonball"), transform, false) as GameObject;

        Cannon.transform.localScale = new Vector3(0.6447f, 0.6447f, 0.6447f);
        Cannon.transform.position   = Cannon.transform.TransformPoint(new Vector3(transform.localPosition.x + xOffset, transform.localPosition.y + yOffset, transform.localPosition.z + zOffset));
        if (direction == "left")
        {
            Cannon.transform.localEulerAngles = new Vector3(0, 0, 90);
        }
        Cannon.GetComponent <Rigidbody2D>().AddForce(transform.up * (speed * playerLevelModifier));
    }
示例#13
0
    public void Deploy(GameObject tile)
    {
        if (cannonToDeploy != null)
        {
            Cannon cannon = cannonToDeploy.GetComponent <Cannon> ();

            if (cannon.ViableDestination(activePlayer, tile))
            {
                cannon.PlaceCannon(tile);
                cannonToDeploy = null;
                activePlayer.GetComponent <CannonManager> ().cannonsCreated += 1;
            }
        }
        else if (pirateToDeploy != null)
        {
            Pirate pirate = pirateToDeploy.GetComponent <Pirate> ();

            if (pirate.ViableDestination(activePlayer, tile))
            {
                pirate.PlacePirate(tile);
                activePlayer.GetComponent <PirateManager> ().piratesCreated += 1;
                pirateToDeploy = null;
            }
        }

        else if (ammoDepotToDeploy != null)
        {
            Depot depotAmmo = ammoDepotToDeploy.GetComponent <Depot> ();

            if (depotAmmo.ViableDestination(activePlayer, tile))
            {
                depotAmmo.PlaceDepot(tile);
                activePlayer.GetComponent <DepotManager> ().ammoDepotsCreated += 1;
                ammoDepotToDeploy = null;
            }
        }

        else if (woodDepotToDeploy != null)
        {
            Depot depotWood = woodDepotToDeploy.GetComponent <Depot> ();

            if (depotWood.ViableDestination(activePlayer, tile))
            {
                depotWood.PlaceDepot(tile);
                activePlayer.GetComponent <DepotManager> ().woodDepotsCreated += 1;
                woodDepotToDeploy = null;
            }
        }
    }
示例#14
0
        public AimAssistance(Game Game, Cannon SourceObject)
            : base(Game)
        {
            this.SourceObject = SourceObject;

            if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL)
            {
                Colour = new Color(0, 0, 0, 192);
                Thickness = 3;
                FillColour = new Color(255, 255, 255, 25);
            }
            else if (Game.GraphicsMode == Game.GRAPHICSMODE_BLUEPRINT)
            {
                Colour = new Color(255, 255, 255, 255);
                Thickness = 1;
                FillColour = new Color(255, 255, 255, 15);
            }

            // Reticle
            Reticle = new DisplayObject();
            Reticle.Visible = false;
            AddChild(Reticle);

            UpdateReticle();

            // Aiming Lines
            LineCenter = new RectangleShape(new Vector2f(Utils.Distance(new Vector2f(0, 48), new Vector2f(0, Game.Size.X - 48)), Thickness));
            LineCenter.FillColor = Colour;
            LineCenter.Origin = new Vector2f(0, Thickness / 2);
            LineCenter.Position = new Vector2f(0, 48);
            LineCenter.Rotation = 90;
            AddChild(LineCenter);

            LineLeft = new RectangleShape(new Vector2f(10, Thickness));
            LineLeft.FillColor = Colour;
            LineLeft.Origin = new Vector2f(0, Thickness / 2);
            LineLeft.Position = new Vector2f(11, 43);
            AddChild(LineLeft);

            LineRight = new RectangleShape(new Vector2f(10, Thickness));
            LineRight.FillColor = Colour;
            LineRight.Origin = new Vector2f(0, Thickness / 2);
            LineRight.Position = new Vector2f(-11, 43);
            AddChild(LineRight);

            Fill = new ConvexShape(4);
            Fill.FillColor = FillColour;
            AddChild(Fill);
        }
示例#15
0
        public override void SetCannons()
        {
            // Tests Purpose
            //base.SetCannons();
            // Creating Cannons
            leftZeroCannon   = new Cannon();
            leftOneCannon    = new Cannon();
            leftTwoCannon    = new Cannon();
            leftThreeCannon  = new Cannon();
            leftFourCannon   = new Cannon();
            rightZeroCannon  = new Cannon();
            rightOneCannon   = new Cannon();
            rightTwoCannon   = new Cannon();
            rightThreeCannon = new Cannon();
            rightFourCannon  = new Cannon();
            centralCannon    = new Cannon();
            // Defining Cannons
            var Cannons = new Cannon[]
            {
                leftZeroCannon,
                leftOneCannon,
                leftTwoCannon,
                leftThreeCannon,
                leftFourCannon,
                rightFourCannon,
                rightThreeCannon,
                rightTwoCannon,
                rightOneCannon,
                rightZeroCannon,
                centralCannon
            };

            lateralCannons = new Cannon[]
            {
                leftZeroCannon,
                leftOneCannon,
                leftTwoCannon,
                leftThreeCannon,
                leftFourCannon,
                rightZeroCannon,
                rightOneCannon,
                rightTwoCannon,
                rightThreeCannon,
                rightFourCannon,
            };
            //
            this.Cannons = Cannons;
            RepositionCannons(Bounds);
        }
示例#16
0
        public Physics(Game game, Player player, ContentManager Content, TanksOnAHeightmap.GameBase.Shapes.Terrain terrain, Space space)
        {
            Cannon = new Cannon(game, player.tank);
            CannonBallManager = new CannonBallManager(game);
            EnemyCannon.playerTank = player.tank;

            healthManager = new HealthManager(game, space);
            this.Content = Content;
            this.Components = game.Components;
            this.game = game;
            this.player = player;
            this.tank = player.tank;
            this.terrain = terrain;
            this.space = space;
        }
 protected override void OnLocationChange(Point3D oldLoc)
 {
     if (Cannon == null)
     {
         Cannon    = new CannonWest(this);
         Direction = Direction.West;
         Cannon.MoveToWorld(new Point3D(X - 3, Y, Z), Map);
     }
     else
     {
         Direction = Direction.West;
         Cannon.MoveToWorld(new Point3D(X - 3, Y, Z), Map);
     }
     base.OnLocationChange(oldLoc);
 }
示例#18
0
    void SelfDestruct()
    {
        Cannon cannon = linker.firstObject.GetComponent <Cannon>();

        if (cannon != null)
        {
            cannon.harpoonAvailable = true;
        }
        else
        {
            EnemyShipAi enemyShipAi = linker.firstObject.GetComponent <EnemyShipAi>();
            enemyShipAi.harpoonAvailable = true;
        }
        Destroy(gameObject);
    }
        protected AbstractFractionController(float interval, GDGameScreen owner, Cannon cannon, Fraction fraction, bool singleUpdatePerCycle)
        {
            updateInterval   = interval;
            onlySingleUpdate = singleUpdatePerCycle;
            Cannon           = cannon;
            Fraction         = fraction;
            Owner            = owner;

            if (fraction.IsPlayer)
            {
                timeSinceLastUpdate = 0f;
            }

            innerBoundings = new FCircle(Cannon.Position, Cannon.Scale * Cannon.CANNON_OUTER_DIAMETER / 2);
        }
示例#20
0
    void Awake()
    {
        m_health = GetComponent<Health>();
        m_cannon = GetComponentInChildren<Cannon>();
        m_multicollider = GetComponent<Multicollider>();

        m_health.Died += Died;

        m_insideBarrier = false;

        if (m_config.aimAtPlayer)
        {
            m_player = GameObject.FindWithTag("Player").GetComponent<Transform>();
        }
    }
 protected override void OnLocationChange(Point3D oldLoc)
 {
     if (Cannon == null)
     {
         Cannon    = new CannonSouth(this);
         Direction = Direction.South;
         Cannon.MoveToWorld(new Point3D(X, Y + 1, Z), Map);
     }
     else
     {
         Direction = Direction.South;
         Cannon.MoveToWorld(new Point3D(X, Y + 1, Z), Map);
     }
     base.OnLocationChange(oldLoc);
 }
示例#22
0
    private void OnTriggerEnter(Collider other)
    {
        Cannon cannon = other.gameObject.GetComponent <Cannon>();

        if (cannon == null)
        {
            return;
        }
        if (cannon.Reflected)
        {
            Debug.Log("goodbye");
            Instantiate(VFXManager.Instance._tankExplosionPrefab, transform.position, Quaternion.identity);
            Destroy(cannon.gameObject);
            Destroy(gameObject);
        }
    }
示例#23
0
        public override void SetCannons()
        {
            // This Tank must not have Cannons
            Cannons = new Cannon[] { };
            // Defining Shields
            var shield = new Shield()
            {
                Support   = this,
                TeamColor = TeamColor.DimGray,
            };

            Shields = new Shield[] { shield };
            // Defining Standard Property Values
            Power *= 3;
            RepositionCannons(Bounds);
        }
示例#24
0
    public void Select(Cannon targetCannon)
    {
        foreach (var cannon in cannons)
        {
            if (cannon == targetCannon)
            {
                cannon.isSelected = true;
            }
            else
            {
                cannon.isSelected = false;
            }
        }

        cannonSelected = targetCannon;
    }
示例#25
0
        public override void SetCannons()
        {
            // Tests Purpose
            //base.SetCannons();
            // Creating Cannons
            cannon = new Cannon();
            // Defining Cannons
            var Cannons = new Cannon[]
            {
                cannon,
            };

            //
            this.Cannons = Cannons;
            RepositionCannons(Bounds);
        }
示例#26
0
 // Start is called before the first frame update
 void Start()
 {
     audio             = GetComponent <AudioSource>();
     greenLaserIsAbove = false;
     greenLaserActive  = false;
     beamSpawned       = false;
     cannonSpawned     = false;
     isRunning         = false;
     cannonRunning     = false;
     engineEvent       = GameObject.Find("EngineParent").GetComponent <EngineEvent7>();
     cannon            = GameObject.Find("Cannon");
     cannonScript      = GameObject.Find("PivotPoint").GetComponent <Cannon>();
     greenLaser        = GameObject.Find("GreenLaserParent");
     rocketCount       = 0;
     levelEnd          = false;
 }
示例#27
0
    Cannon GetClosestCannon(Vector3 _src)
    {
        Cannon closestCannon = null;
        float  minDist       = float.MaxValue;

        foreach (var elem in GlobalManager.cannons)
        {
            float currentDist = Vector3.Distance(elem.transform.position, _src);
            if (minDist > currentDist)
            {
                minDist       = currentDist;
                closestCannon = elem;
            }
        }
        return(closestCannon);
    }
示例#28
0
 public override void SetCannons()
 {
     rocketeerCannon = new RocketeerCannon();
     stereoCannon    = new Cannon()
     {
         Stereo    = true,
         ShootRate = -Int32.MaxValue,
     };
     //
     Cannons = new Cannon[]
     {
         rocketeerCannon,
         stereoCannon
     };
     RepositionCannons(Bounds);
 }
示例#29
0
    public void Spawn(Element e, Vector3 aim, Vector3 dir, Cannon c)
    {
        gameObject.SetActive(true);
        explodeTime = 250; //TODO hard coded number
        explodeTimer.Reset();
        explodeTimer.Start();
        element            = e;
        transform.position = aim;
        traj   = dir;
        cannon = c;
        transform.renderer.material = Reference.elements[element].mat;

        float rad = initRad * radPowUp;

        SetRad(rad);
    }
示例#30
0
    private void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.moveDirection.y < -0.3F)
        {
            return;
        }

        //recursively find Cannon; Cannon doesn't have hitbox, its children do
        GameObject gObj = RecursivelyCheckTag(hit.gameObject, "Cannon");

        if (gObj != null)
        {
            Cannon cannon = gObj.GetComponent <Cannon>();
            cannon.PlayerCollide(this.gameObject);
        }
    }
示例#31
0
    protected override void Start()
    {
        name     = "Cannon";
        Instance = this;

        //var meshFilter = GetComponent<MeshFilter>();
        //Mesh = (meshFilter.mesh = new Mesh());
        //RebuildMesh();

        base.Start();
        ray1   = gameObject.FindChild("canon").FindChild("ray1");
        ray2   = gameObject.FindChild("canon").FindChild("ray2");
        bullet = gameObject.FindChild("canon").FindChild("Bullet").FindChild("itm_sphere_invert");

        ray1.renderer.enabled = ray2.renderer.enabled = bullet.renderer.enabled = false;
    }
示例#32
0
文件: Enemy.cs 项目: Donczakos/Repo
    void FindClosestCannon()
    {
        List <Cannon> cannons = Cannon.All;

        foreach (Cannon c in cannons)
        {
            if (target == null)
            {
                target = c;
            }
            if (Vector3.Distance(this.transform.position, target.transform.position) > Vector3.Distance(this.transform.position, c.transform.position))
            {
                target = c;
            }
        }
    }
    public void cannonEnemySpawn()
    {
        //Debug.Log("here");
        //if (!isServer) { return; }
        //Debug.Log("in");
        cannon = new Cannon();
        array  = new int[, ] {
            { 5, 2, 6, 1 },
            { 5, 2, 4, 2 },
            { 1, 1, 8, 1 },
            { 1, 1, 8, 1 },
        };
        int[,] A = array;
        int[,] B = (int[, ])A.Clone();
        int[,] D = (int[, ])A.Clone();
        int[,] E = (int[, ])A.Clone();
        int[,] C = new int[size, size];
        sC       = cannon.matrixToString(C, size);
        //for (int i = 0; i < C.Length; i++)
        //C[i] = new int[A.Length];
        for (int i = 0; i < root_p; i++)
        {
            for (int j = 0; j < i; j++)
            {
                A = cannon.ShiftLeft(A, i);
            }
        }
        sA = cannon.matrixToString(A, size);
        //Debug.Log(sA);

        for (int i = 0; i < root_p; i++)
        {
            for (int j = 0; j < i; j++)
            {
                B = cannon.ShiftUp(B, i);
            }
        }

        sB = cannon.matrixToString(B, size);
        //Debug.Log(sB);
        generateInds();

        //printMatrix(C, Convert.ToInt16(Math.Sqrt(A.Length)));

        int[,] localC = cannon.MatrixProduct(D, E, size);
        cannon.printMatrix(localC, size);
    }
示例#34
0
            public Cannons(Vector2f enemyPosition, Vector2f enemyDimensions)
            {
                cannonCounter = 1.0f;

                //Cannon1
                var cannonPosition = new Vector2f(enemyPosition.X + enemyDimensions.X / 3,
                                                  enemyPosition.Y - enemyDimensions.Y / 2);
                var bulletVector = new Vector2f(2 * WindowProperties.ScaleX,
                                                -4.7f * WindowProperties.ScaleY);

                Cannon1 = new Cannon(cannonPosition, bulletVector);

                //Cannon2
                cannonPosition = new Vector2f(enemyPosition.X,
                                              enemyPosition.Y - enemyDimensions.Y / 2);
                bulletVector = new Vector2f(0 * WindowProperties.ScaleX,
                                            -4.7f * WindowProperties.ScaleY);
                Cannon2 = new Cannon(cannonPosition, bulletVector);

                //Cannon3
                cannonPosition = new Vector2f(enemyPosition.X - enemyDimensions.X / 3,
                                              enemyPosition.Y - enemyDimensions.Y / 2);
                bulletVector = new Vector2f(-2 * WindowProperties.ScaleX,
                                            -4.7f * WindowProperties.ScaleY);
                Cannon3 = new Cannon(cannonPosition, bulletVector);

                //Cannon4
                cannonPosition = new Vector2f(enemyPosition.X,
                                              enemyPosition.Y + enemyDimensions.Y / 2);
                bulletVector = new Vector2f(0 * WindowProperties.ScaleX,
                                            4.7f * WindowProperties.ScaleY);
                Cannon4 = new Cannon(cannonPosition, bulletVector);

                //Cannon5
                cannonPosition = new Vector2f(enemyPosition.X + enemyDimensions.X / 2.4f,
                                              enemyPosition.Y + enemyDimensions.Y / 18);
                bulletVector = new Vector2f(5.13f * WindowProperties.ScaleX,
                                            1 * WindowProperties.ScaleY);
                Cannon5 = new Cannon(cannonPosition, bulletVector);

                //Cannon6
                cannonPosition = new Vector2f(enemyPosition.X - enemyDimensions.X / 2.4f,
                                              enemyPosition.Y + enemyDimensions.Y / 18);
                bulletVector = new Vector2f(-5.13f * WindowProperties.ScaleX,
                                            1 * WindowProperties.ScaleY);
                Cannon6 = new Cannon(cannonPosition, bulletVector);
            }
示例#35
0
    public static void DeployUnits()
    {
        string  prefabpath = "Prefabs/";
        string  prefabName;
        HexCell h;

        foreach (UnitOrder uO in instance.uoList)
        {
            h           = MapMaster.Map[uO.R, uO.Q];
            prefabName  = ((UnitTypes)uO.unitType).ToString();
            prefabName += prefabName == "Cannon" ? "" : PlayerMaster.CurrentTurn.ToString();

            Unit u = ((GameObject)GameObject.Instantiate(Resources.Load(prefabpath + prefabName), h.SpawnVector, Quaternion.identity)).GetComponent <Unit>();

            u.UDirection = (int)(PlayerMaster.CurrentTurn == 0 ? UnitRotations.half : UnitRotations.none);
            u.Player     = PlayerMaster.CurrentTurn;
            u.gameObject.transform.rotation = u.URotation();

            MapMaster.Map[uO.R, uO.Q].Unit            = u;
            MapMaster.Map[uO.R, uO.Q].Unit.CurrentHex = MapMaster.Map[uO.R, uO.Q];


            switch (uO.unitType)
            {
            case (0):
                PlayerMaster.CurrentPlayer.Inf.Add(u);
                break;

            case (1):
                PlayerMaster.CurrentPlayer.Cav.Add(u);
                break;

            case (2):
                Cannon c = (Cannon)u;
                c.shots = 0;
                PlayerMaster.CurrentPlayer.Can.Add(c);
                break;
            }

            GameObject.Destroy(uO.icon);

            ScoreMaster.GivePoints(ScoreMaster.PointValues[uO.unitType], u.Player);
        }

        instance.uoList.Clear();
        RefreshUnitsUsed();
    }
示例#36
0
        public override void SetCannons()
        {
            // Tests Purpose
            //base.SetCannons();
            // Creating Cannons
            cannon           = new Cannon();
            cannon.ShootRate = SkillsManager.StandardShootRate * .5f;
            // Defining Cannons
            var Cannons = new Cannon[]
            {
                cannon,
            };

            //
            this.Cannons = Cannons;
            RepositionCannons(Bounds);
        }
示例#37
0
    public override GameObject spawn()
    {
        GameObject spawnedObject = base.spawn();
        Cannon     cannon        = FindCannon(spawnedObject);

        //Safty just in case we try to spawn another player while the player is still alive
        if (GameObject.FindWithTag("Player") != null)
        {
            Destroy(GameObject.FindWithTag("Player").gameObject);
        }
        if (cannon != null)
        {
            //TODO find an easier way to assign this
            GameObject.FindWithTag("Gui").transform.FindChild("AmmoText").gameObject.GetComponent <AmmoText> ().cannon = cannon;
        }
        return(spawnedObject);
    }
示例#38
0
 public override void SetCannons()
 {
     // Creating Cannons
     leftTopCannon   = new DroneCannon();
     leftDownCannon  = new DroneCannon();
     rightTopCannon  = new DroneCannon();
     rightDownCannon = new DroneCannon();
     // Setting Cannons
     Cannons = new Cannon[]
     {
         leftTopCannon,
         leftDownCannon,
         rightTopCannon,
         rightDownCannon
     };
     RepositionCannons(Bounds);
 }
示例#39
0
        protected override void Initialize()
        {
            _screenWidth = GraphicsDevice.Viewport.Width;
            _screenHeight = GraphicsDevice.Viewport.Height;

            _background = new Background();
            _tank = new Tank();
            _cannon = new Cannon();
            _bullet = new Bullet();
            _alien = new Alien();
            _explosion = new Explosion();
            _particleList = new List<ParticleData>();

            _tankPositionX = _screenWidth/2;
            _tankPositionY = _screenHeight - 193;
            base.Initialize();
        }
示例#40
0
        public void Given_APreviouslyUsedCannon_When_Resetting_Then_ThecannonShouldBeReset()
        {
            var cannon   = Cannon.GetInstance();
            var distance = 1000;

            cannon.TargetDistance = distance;

            var attempt = new CannonShotAttempt(45, 1);
            var result  = cannon.Shoot(attempt);

            var attemptCount = cannon.PreviousShotResults.Count;

            cannon.Reset();

            Assert.AreNotEqual(distance, cannon.TargetDistance);
            Assert.AreNotEqual(attemptCount, cannon.PreviousShotResults.Count);
        }
示例#41
0
 public override void SetCannons()
 {
     // Creating Cannons
     topCannon   = new DroneCannon();
     leftCannon  = new DroneCannon();
     rightCannon = new DroneCannon();
     downCannon  = new DroneCannon();
     // Setting Cannons
     Cannons = new Cannon[]
     {
         topCannon,
         leftCannon,
         rightCannon,
         downCannon,
     };
     RepositionCannons(Bounds);
 }
示例#42
0
    void LuoAseValikko()
    {
        // Asevalikko
        Inventory inventory = new Inventory();
        inventory.Y = Screen.Top - 20;
        Add(inventory);

        Weapon rynkky = new AssaultRifle(20, 10);
        Weapon plasma = new PlasmaCannon(20, 10);
        Weapon kanuuna = new Cannon(20,10);
        kanuuna.Image = Inventory.ScaleImageDown(kanuuna.Image, 4);

        inventory.AddItem(rynkky, rynkky.Image);
        inventory.AddItem(plasma, plasma.Image);
        inventory.AddItem(kanuuna, kanuuna.Image);
        inventory.ItemSelected += AseValittu;

        // Valitse pelin aluksi rynkky
        inventory.SelectItem(rynkky);
    }
示例#43
0
 void Awake()
 {
     ship = GameObject.FindGameObjectWithTag (Tags.ship).GetComponent<Ship> ();
     cannon = GameObject.FindGameObjectWithTag (Tags.cannon).GetComponent<Cannon> ();
 }
 void OnEnable()
 {
     cannon = (Cannon)target;
     transform = cannon.transform;
     barrel = cannon.transform.Find("Barrel");
 }
示例#45
0
        void ReloadLevel()
        {
            if (scene != null)
            {
                SetLevelState();

                scene.UnloadContent();
                withChicks.UnloadContent();
            }
            //if (blank != null)
            {
                blank = null;
                LowerFlag(Jabber.Flags.FADE_OUT);
            }
            IsQuitting = false;
            Components.Clear();

            world = new FarWorld();
            world.Initialize(new Vector2(0, -15.0f));
            world.SimulationSpeedFactor = 1.0f;

            withChicks = new ChicksScene(this, world, Content);
            withChicks.DoWorldUpdateDraw = false;
               // withChicks.AddNode(cannon);

            scene = new ThisGamesScene(this, world, withChicks, Content);
            scene.DoWorldUpdateDraw = false;

            scene.AddTextureLoadInterceptor("textures\\Physical\\wood", "break", "break_frames", "wood");
            scene.AddTextureLoadInterceptor("textures\\Physical\\cement", "break", "break_frames", "cement");
            scene.AddTextureLoadInterceptor("textures\\Physical\\glass", "break", "break_frames", "glass");

            scene.AddTextureLoadInterceptor("textures\\Backgrounds\\Bavaria\\cowright", "textures/backgrounds/bavaria/bavaria", "textures/backgrounds/bavaria/bavaria_frames", "cowleft");
            scene.AddTextureLoadInterceptor("textures\\Backgrounds\\Bavaria\\cowleft", "textures/backgrounds/bavaria/bavaria", "textures/backgrounds/bavaria/bavaria_frames", "cowright");

            LevelDir = "Content/Levels/" + location + "/Level" + levelNum + ".xml";
            scene.LoadGScene(LevelDir);

            withChicks.startPos = scene.startPos;

            ChickenDrawer chickdrawer = new ChickenDrawer(withChicks, scene);
            chickdrawer.Initialize(Content);
            scene.AddNode(chickdrawer);

            ChickenBience bience = new ChickenBience(this);
            bience.Initialize(Content);
            bience.Position = scene.startPos;
            scene.AddNode(bience);

            cannon = new Cannon(this);
            cannon.Position = scene.startPos;
            cannon.Initialize(Content);
            scene.AddNode(cannon);
            //scene.AddNode(cannon);

            if (withChicks.GetRightMaxPos() > scene.GetRightMaxPos())
            {
                rightMostPos = withChicks.GetRightMaxPos() + 200.0f;
            }
            else
            {
                rightMostPos = scene.GetRightMaxPos() + 200.0f;
            }

            leftMostPos = scene.startPos.X - 500;
            /// rightMostPos = 10000000;
            world.SetCollisionForAll(Fox.FOX_NONE_COLLISION_GROUP, false);
            world.SetCollisionForAll(BreakableBody.BodyNoneCollisionGroup, false);

            string country = scene.countryName;
            //scene.ToFire.Clear();
            if (scene.ToFire.Count == 0)
                for (int i = 0; i < 4; i++)
                {
                    scene.ToFire.Add(0);
                }
            //GameScene worldLoc = new GameScene(world, Content);
            //WorldLocation.CreateVesuvius(scene, (int)leftMostPos, (int)rightMostPos);

               // WorldLocation.CreatePolar(scene, (int)leftMostPos, (int)rightMostPos);

            switch (scene.countryName)
            {
                case "bavaria":
                    WorldLocation.CreateBavaria(scene, (int)leftMostPos, (int)rightMostPos);
                    break;
                case "paris":
                    WorldLocation.CreateParis(scene, (int)leftMostPos, (int)rightMostPos);
                    break;
                case "australia":
                    WorldLocation.CreateAustralia(scene, (int)leftMostPos, (int)rightMostPos);
                    break;
                case "polar":
                    WorldLocation.CreatePolar(scene, (int)leftMostPos, (int)rightMostPos);
                    break;
                case "vesuvius":
                    WorldLocation.CreateVesuvius(scene, (int)leftMostPos, (int)rightMostPos);
                    break;
            }

            feathers.RaiseFlag(Jabber.Flags.FADE_OUT);
            Components.Add(scene);
            Components.Add(withChicks);

            MenuObj pause = new Button("ui/ui");
            pause.Initialize(Content);
            pause.Name = "pause";
            pause.CreateFramesFromXML("ui/ui_frames");
            pause.CurrentFrame = "pause";
            pause.ResetDimensions();
            pause.UniformScale = ScaleFactor;
            (pause as Button).RegularScale = ScaleFactor;
            (pause as Button).ScaleOnHover = (pause as Button).RegularScale * 1.4f;
            pause.PosX = -Jabber.BaseGame.Get.BackBufferWidth / 2.0f + pause.Width * pause.ScaleX;
            pause.PosY = Jabber.BaseGame.Get.BackBufferHeight / 2.0f - pause.Height * pause.ScaleY;
            Components.Add(pause);

            forceEndGame = new Button("ui/ui");
            forceEndGame.Initialize(Content);
            forceEndGame.UniformScale = 0.001f;
            forceEndGame.Name = "forceendgame";
            forceEndGame.CreateFramesFromXML("ui/ui_frames");
            forceEndGame.CurrentFrame = "doublearrow";
            forceEndGame.ResetDimensions();
            forceEndGame.RegularScale = 0.0f;// ScaleFactor * 0.35f;
            forceEndGame.ScaleOnHover = 0.0f;// ScaleFactor * 1.1f * 0.35f;
            forceEndGame.PosX = -Jabber.BaseGame.Get.BackBufferWidth / 2.0f + pause.Width * pause.ScaleX;
            forceEndGame.PosY = Jabber.BaseGame.Get.BackBufferHeight / 2.0f - pause.Height * pause.ScaleY * 2.3f;
            Components.Add(forceEndGame);
            forceEndGame.RaiseFlag(Flags.PASSRENDER);

            float widthHeightToUse = pause.Width;

            pause = new Button("ui/ui");
            pause.Initialize(Content);
            pause.Name = "restart";
            pause.Colour = Color.Green;
            pause.CreateFramesFromXML("ui/ui_frames");
            pause.CurrentFrame = "restart";
            (pause as Button).RegularScale = ScaleFactor;
            (pause as Button).ScaleOnHover = (pause as Button).RegularScale * 1.4f;
            pause.ResetDimensions();
            pause.UniformScale = ScaleFactor;
            pause.Width = pause.Height = widthHeightToUse;
            pause.PosX = -Jabber.BaseGame.Get.BackBufferWidth / 2.0f + pause.Width * pause.ScaleX * 2.5f;
            pause.PosY = Jabber.BaseGame.Get.BackBufferHeight / 2.0f - pause.Height * pause.ScaleY;
            Components.Add(pause);

            maxNumFox = 0;
            maxNumDonuts = 0;
            for (int i = 0; i < scene.Nodes.Count; i++)
            {
                if (scene.Nodes[i] is Fox)
                {
                    ++maxNumFox;
                }
                else if (scene.Nodes[i] is Donut)
                {
                    ++maxNumDonuts;
                }
                else if (scene.Nodes[i] is DonutCase)
                {
                    maxNumDonuts += 5;
                }
            }

            donutScore = new DonutScore();
            donutScore.Initialize(Content);
            scene.AddNode(donutScore);

            score = new Score(scene, this.location, levelNum);
            score.Initialize(Content);
            scene.AddNode(score);

            AudioQueue q = new AudioQueue(this);
            q.Initialize(Content);

            scene.AddNode(q);
        }
示例#46
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            cannonModel = new Cannon();
            bulletModel = new Bullet(vel);
            ballsModel = new Balls[3];

            balls = new Vector2[3];

            nroBullets = 0;
            score = 0;
            hasShot = false;
            isMoving = false;

            base.Initialize();
        }
示例#47
0
	public Character SpawnCharacter(CharacterData.CharacterClassType classType, int charModeType, int camp, int level, Vector3 pos, Vector3 dir, CharacterStatus.Pose pose){
		this.START_METHOD("SpawnCharacter");
		Character tempChar = null;
		//create the enemies
		if (classType == CharacterData.CharacterClassType.CHARACTER) {
			//create the enemy
			if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.BOWMAN){
				Bowman chara = new Bowman();
				chara.SetArmor(armorList[0]);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			}
//			} else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.GIANT){
//				Gaint chara = new Gaint("giant");
//				SetEnemy(chara,pos,dir,camp,pose,0.02f,20);
//				tempChar = chara;
//			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.VIKING){
				Viking chara = new Viking();
				chara.SetArmor(armorList[1]);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,30);
				tempChar = chara;
			}
			//create enemy2
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY2){
				Gaint chara = new Gaint("enemy2");
				chara.SetArmor(armorList[2]);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			//enemy3
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY3){
				Gaint chara = new Gaint("enemy3");
				chara.SetArmor(armorList[3]);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			//enemy4
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY4){
				Gaint chara = new Gaint("enemy4");
				chara.SetArmor(armorList[4]);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY5){
				Gaint chara = new Gaint("enemy5");
				chara.SetArmor(armorList[5]);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY6){
				Gaint chara = new Gaint("enemy6");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY7){
				Gaint chara = new Gaint("enemy7");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY8){
				Gaint chara = new Gaint("enemy8");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY9){
				Gaint chara = new Gaint("enemy9");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY10){
				Gaint chara = new Gaint("enemy10");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY11){
				Gaint chara = new Gaint("enemy11");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY12){
				Gaint chara = new Gaint("enemy12");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY13){
				Gaint chara = new Gaint("enemy13");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY14){
				Gaint chara = new Gaint("enemy14");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY15){
				Gaint chara = new Gaint("enemy15");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY16){
				Gaint chara = new Gaint("enemy16");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY17){
				Gaint chara = new Gaint("enemy17");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 

			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY19){
				Gaint chara = new Gaint("enemy19");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY20){
				Gaint chara = new Gaint("enemy20");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY21){
				Gaint chara = new Gaint("enemy21");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY22){
				Gaint chara = new Gaint("enemy22");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 

			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY24){
				Gaint chara = new Gaint("enemy24");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY25){
				Gaint chara = new Gaint("enemy25");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 

			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY27){
				Gaint chara = new Gaint("enemy27");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY28){
				Gaint chara = new Gaint("enemy28");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY30){
				Gaint chara = new Gaint("enemy30");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY31){
				Gaint chara = new Gaint("enemy31");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY32){
				Gaint chara = new Gaint("enemy32");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY33){
				Gaint chara = new Gaint("enemy33");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY34){
				Gaint chara = new Gaint("enemy34");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY35){
				Gaint chara = new Gaint("enemy35");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY36){
				Gaint chara = new Gaint("enemy36");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY37){
				Gaint chara = new Gaint("enemy37");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY38){
				Gaint chara = new Gaint("enemy38");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY39){
				Gaint chara = new Gaint("enemy39");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 

			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY41){
				Gaint chara = new Gaint("enemy41");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 

			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY43){
				Gaint chara = new Gaint("enemy43");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY44){
				Gaint chara = new Gaint("enemy44");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY45){
				Gaint chara = new Gaint("enemy45");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY46){
				Gaint chara = new Gaint("enemy46");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.BOSS1){
				Gaint chara = new Gaint("boss1");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.BOSS2){
				Gaint chara = new Gaint("boss2");
				SetEnemy(chara,pos,dir,camp,pose,0.02f,10);
				tempChar = chara;
			} 


			//used enemies model
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY18){
				Gaint chara = new Gaint("enemy18");
				chara.SetArmor(armorList[0]);
				chara.SetIsPonsion(false);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,hpList[0]);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY23){
				Gaint chara = new Gaint("enemy23");
				chara.SetArmor(armorList[1]);
				chara.SetIsPonsion(false);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,hpList[1]);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY26){
				Gaint chara = new Gaint("enemy26");
				chara.SetArmor(armorList[2]);
				chara.SetIsPonsion(false);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,hpList[2]);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY29){
				Gaint chara = new Gaint("enemy29");
				chara.SetArmor(armorList[3]);
				chara.SetIsPonsion(false);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,hpList[3]);
				tempChar = chara;
			}
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY40){
				Gaint chara = new Gaint("enemy40");
				chara.SetArmor(armorList[4]);
				chara.SetIsPonsion(false);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,hpList[4]);
				tempChar = chara;
			} 
			else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.ENEMY42){
				Gaint chara = new Gaint("enemy42");
				chara.SetArmor(armorList[5]);
				chara.SetIsPonsion(false);
				SetEnemy(chara,pos,dir,camp,pose,0.02f,hpList[5]);
				tempChar = chara;
			} 


			if(tempChar != null){
				chars.Add(tempChar);
			} else {
				throw new UnityException("no current char type to spawn!");
			}
		}
		//create the building
		else if (classType == CharacterData.CharacterClassType.BUILDING) {
			//create the barrack to gather resources
			if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.BARRACK){
				TowerBarrack character = new TowerBarrack();
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetCamp(camp);
				tempChar = character;
			} else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.CANNON){
				Cannon character = new Cannon();
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose (pose);
				character.SetCamp(camp);
				//set attack power
				character.SetAttackPower(50);
				tempChar = character;
			}
			//Tower01
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER1){
				Tower1 character = new Tower1();
				character.SetAttackRange(2.25f);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose (pose);
				character.SetCamp(camp);
				character.SetAttackRate(1f);
				character.SetNeedPower(towerPowerList[0]);
				//set attack power
				character.SetAttackPower(tower1AttackNumber);
				tempChar = character;
			}
			//Tower02
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER2){
				Tower2 character = new Tower2();
				character.SetAttackRange(2);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose (pose);
				character.SetCamp(camp);
				character.SetAttackRate(1f);
				character.SetNeedPower(towerPowerList[1]);
				//set attack power
				character.SetAttackPower(tower2AttackNumber);
				tempChar = character;
			}
			//Tower4
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER4){
				Tower4 character = new Tower4();
				character.SetAttackRange(2);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetNeedPower(towerPowerList[2]);
				tempChar = character;
			}
			//Tower7
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER7){
				Tower7 character = new Tower7();
				character.SetAttackRange(2.5f);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackPower(tower7AttackNumber);
				character.SetAttackRate(1f);
				character.SetNeedPower(towerPowerList[3]);
				tempChar = character;
			}
			//Tower10
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER10){
				Tower10 character = new Tower10();
				character.SetAttackRange(2.5f);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackPower(tower10AttackNumber);
				character.SetAttackRate(1f);
				character.SetNeedPower(towerPowerList[4]);
				tempChar = character;
			}
			//Research
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.LAB){
				Research character = new Research();
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Diamond Resource
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.DIAMOND){
				DiamondResource character = new DiamondResource();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Small Mine
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.MINE1){
				SmallMine character = new SmallMine();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Large Mine
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.MINE2){
				LargeMine character = new LargeMine();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Small Geneator
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.GENERATOR1){
				SmallGeneator character = new SmallGeneator();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Large Geneator
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.GENERATOR2){
				LargeGeneator character = new LargeGeneator();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Targeting Facility
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TARGETING){
				TargetingFacility character = new TargetingFacility();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackRange(1);
				character.SetNeedPower(towerPowerList[5]);
				tempChar = character;
			}
			//Super Capacitor
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.CAPACITOR){
				SuperCapacitor character = new SuperCapacitor();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackRange(1);
				character.SetNeedPower(towerPowerList[6]);
				tempChar = character;
			}
			//Alien Recovery
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.ALIEN){
				AlienRecovery character = new AlienRecovery();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackRange(2);
				tempChar = character;
			}
			//Antenna
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.ANTENNA){
				Antenna character = new Antenna();
				character.SetPos(pos);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackRange(antennaRange);
				tempChar = character;
			}
			//created the tower, add to the building list
			if(tempChar != null){
				building.Add(tempChar);
			} else { 
				throw new UnityException("no current building type to spawn!");
			}
		}
		//add to the all character list
		allCharacter.Add (tempChar);
		this.END_METHOD("SpawnCharacter");
		return tempChar;
	}
示例#48
0
 public void ResetPowerups()
 {
     m_singleShot.Config = m_singleShotConfig;
     m_tripleShot.Config = m_tripleShotConfig;
     m_cannon = m_singleShot;
 }
示例#49
0
 static void Main()
 {
     int sx1 = int.Parse(Console.ReadLine());
     int sy1 = int.Parse(Console.ReadLine());
     int sx2 = int.Parse(Console.ReadLine());
     int sy2 = int.Parse(Console.ReadLine());
     int h = int.Parse(Console.ReadLine());
     int cx1 = int.Parse(Console.ReadLine());
     int cy1 = int.Parse(Console.ReadLine());
     int cx2 = int.Parse(Console.ReadLine());
     int cy2 = int.Parse(Console.ReadLine());
     int cx3 = int.Parse(Console.ReadLine());
     int cy3 = int.Parse(Console.ReadLine());
     Ship myShip = new Ship(sx1, sy1, sx2, sy2);
     Cannon FirstCannon = new Cannon(cx1, cy1, h);
     Cannon SeconCannon = new Cannon(cx2, cy2, h);
     Cannon ThirdCannon = new Cannon(cx3, cy3, h);
     myShip.GetHitDamage(FirstCannon.targetX, FirstCannon.targetY);
     myShip.GetHitDamage(SeconCannon.targetX, SeconCannon.targetY);
     myShip.GetHitDamage(ThirdCannon.targetX, ThirdCannon.targetY);
     Console.WriteLine(myShip.damage + "%");
 }
示例#50
0
 void Start()
 {
     cannon = GameObject.Find("Cannon").GetComponent<Cannon>();
 }
示例#51
0
 // Use this for initialization
 void Start()
 {
     cannon = gameObject.GetComponent<Cannon> ();
     //pc = gameObject.GetComponent<PlayerController> ();
     tf = gameObject.GetComponent<Transform> ();
 }
示例#52
0
        public Item Construct()
        {
            if ( m_Type == null )
                return null;

            Item item;

            try
            {
                if ( m_Type == typeofStatic )
                {
                    item = new Static( m_ItemID );
                }
                else if ( m_Type == typeofLocalizedStatic )
                {
                    int labelNumber = 0;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "LabelNumber" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                            {
                                labelNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                                break;
                            }
                        }
                    }

                    item = new LocalizedStatic( m_ItemID, labelNumber );
                }
                else if ( m_Type == typeofLocalizedSign )
                {
                    int labelNumber = 0;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "LabelNumber" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                            {
                                labelNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                                break;
                            }
                        }
                    }

                    item = new LocalizedSign( m_ItemID, labelNumber );
                }
                else if ( m_Type == typeofAnkhWest || m_Type == typeofAnkhNorth )
                {
                    bool bloodied = false;

                    for ( int i = 0; !bloodied && i < m_Params.Length; ++i )
                        bloodied = ( m_Params[i] == "Bloodied" );

                    if ( m_Type == typeofAnkhWest )
                        item = new AnkhWest( bloodied );
                    else
                        item = new AnkhNorth( bloodied );
                }
                else if ( m_Type == typeofMarkContainer )
                {
                    bool bone = false;
                    bool locked = false;
                    Map map = Map.Malas;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i] == "Bone" )
                        {
                            bone = true;
                        }
                        else if ( m_Params[i] == "Locked" )
                        {
                            locked = true;
                        }
                        else if ( m_Params[i].StartsWith( "TargetMap" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                map = Map.Parse( m_Params[i].Substring( ++indexOf ) );
                        }
                    }

                    MarkContainer mc = new MarkContainer( bone, locked );

                    mc.TargetMap = map;
                    mc.Description = "strange location";

                    item = mc;
                }
                else if ( m_Type == typeofHintItem )
                {
                    int range = 0;
                    int messageNumber = 0;
                    string messageString = null;
                    int hintNumber = 0;
                    string hintString = null;
                    TimeSpan resetDelay = TimeSpan.Zero;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "Range" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                        }
                        else if ( m_Params[i].StartsWith( "WarningString" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                messageString = m_Params[i].Substring( ++indexOf );
                        }
                        else if ( m_Params[i].StartsWith( "WarningNumber" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                messageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                        }
                        else if ( m_Params[i].StartsWith( "HintString" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                hintString = m_Params[i].Substring( ++indexOf );
                        }
                        else if ( m_Params[i].StartsWith( "HintNumber" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                hintNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                        }
                        else if ( m_Params[i].StartsWith( "ResetDelay" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                resetDelay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                        }
                    }

                    HintItem hi = new HintItem( m_ItemID, range, messageNumber, hintNumber );

                    hi.WarningString = messageString;
                    hi.HintString = hintString;
                    hi.ResetDelay = resetDelay;

                    item = hi;
                }
                else if ( m_Type == typeofWarningItem )
                {
                    int range = 0;
                    int messageNumber = 0;
                    string messageString = null;
                    TimeSpan resetDelay = TimeSpan.Zero;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "Range" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                        }
                        else if ( m_Params[i].StartsWith( "WarningString" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                messageString = m_Params[i].Substring( ++indexOf );
                        }
                        else if ( m_Params[i].StartsWith( "WarningNumber" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                messageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                        }
                        else if ( m_Params[i].StartsWith( "ResetDelay" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                resetDelay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                        }
                    }

                    WarningItem wi = new WarningItem( m_ItemID, range, messageNumber );

                    wi.WarningString = messageString;
                    wi.ResetDelay = resetDelay;

                    item = wi;
                }
                else if ( m_Type == typeofCannon )
                {
                    CannonDirection direction = CannonDirection.North;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "CannonDirection" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                direction = (CannonDirection)Enum.Parse( typeof( CannonDirection ), m_Params[i].Substring( ++indexOf ), true );
                        }
                    }

                    item = new Cannon( direction );
                }
                else if ( m_Type == typeofSerpentPillar )
                {
                    string word = null;
                    Rectangle2D destination = new Rectangle2D();

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "Word" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                word = m_Params[i].Substring( ++indexOf );
                        }
                        else if ( m_Params[i].StartsWith( "DestStart" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                destination.Start = Point2D.Parse( m_Params[i].Substring( ++indexOf ) );
                        }
                        else if ( m_Params[i].StartsWith( "DestEnd" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                                destination.End = Point2D.Parse( m_Params[i].Substring( ++indexOf ) );
                        }
                    }

                    item = new SerpentPillar( word, destination );
                }
                else if ( m_Type.IsSubclassOf( typeofBeverage ) )
                {
                    BeverageType content = BeverageType.Liquor;
                    bool fill = false;

                    for ( int i = 0; !fill && i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "Content" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                            {
                                content = (BeverageType)Enum.Parse( typeof( BeverageType ), m_Params[i].Substring( ++indexOf ), true );
                                fill = true;
                            }
                        }
                    }

                    if ( fill )
                        item = (Item)Activator.CreateInstance( m_Type, new object[]{ content } );
                    else
                        item = (Item)Activator.CreateInstance( m_Type );
                }
                else if ( m_Type.IsSubclassOf( typeofBaseDoor ) )
                {
                    DoorFacing facing = DoorFacing.WestCW;

                    for ( int i = 0; i < m_Params.Length; ++i )
                    {
                        if ( m_Params[i].StartsWith( "Facing" ) )
                        {
                            int indexOf = m_Params[i].IndexOf( '=' );

                            if ( indexOf >= 0 )
                            {
                                facing = (DoorFacing)Enum.Parse( typeof( DoorFacing ), m_Params[i].Substring( ++indexOf ), true );
                                break;
                            }
                        }
                    }

                    item = (Item)Activator.CreateInstance( m_Type, new object[]{ facing } );
                }
                else
                {
                    item = (Item)Activator.CreateInstance( m_Type );
                }
            }
            catch ( Exception e )
            {
                throw new Exception( String.Format( "Bad type: {0}", m_Type ), e );
            }

            if ( item is BaseAddon )
            {
                //if ( item is MaabusCoffin )
                //{
                //    MaabusCoffin coffin = (MaabusCoffin)item;

                //    for ( int i = 0; i < m_Params.Length; ++i )
                //    {
                //        if ( m_Params[i].StartsWith( "SpawnLocation" ) )
                //        {
                //            int indexOf = m_Params[i].IndexOf( '=' );

                //            if ( indexOf >= 0 )
                //                coffin.SpawnLocation = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
                //        }
                //    }
                //}
                if ( m_ItemID > 0 )
                {
                    List<AddonComponent> comps = ((BaseAddon)item).Components;

                    for ( int i = 0; i < comps.Count; ++i )
                    {
                        AddonComponent comp = (AddonComponent)comps[i];

                        if ( comp.Offset == Point3D.Zero )
                            comp.ItemID = m_ItemID;
                    }
                }
            }
            else if ( item is BaseLight )
            {
                bool unlit = false, unprotected = false;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( !unlit && m_Params[i] == "Unlit" )
                        unlit = true;
                    else if ( !unprotected && m_Params[i] == "Unprotected" )
                        unprotected = true;

                    if ( unlit && unprotected )
                        break;
                }

                if ( !unlit )
                    ((BaseLight)item).Ignite();
                if ( !unprotected )
                    ((BaseLight)item).Protected = true;

                if ( m_ItemID > 0 )
                    item.ItemID = m_ItemID;
            }
            else if ( item is Server.Mobiles.Spawner )
            {
                Server.Mobiles.Spawner sp = (Server.Mobiles.Spawner)item;

                sp.NextSpawn = TimeSpan.Zero;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( m_Params[i].StartsWith( "Spawn" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.SpawnNames.Add( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "MinDelay" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.MinDelay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "MaxDelay" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.MaxDelay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "NextSpawn" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.NextSpawn = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Count" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.Count = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Team" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.Team = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "HomeRange" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.HomeRange = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Running" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.Running = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Group" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            sp.Group = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                }
            }
            else if ( item is RecallRune )
            {
                RecallRune rune = (RecallRune)item;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( m_Params[i].StartsWith( "Description" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            rune.Description = m_Params[i].Substring( ++indexOf );
                    }
                    else if ( m_Params[i].StartsWith( "Marked" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            rune.Marked = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "TargetMap" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            rune.TargetMap = Map.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Target" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            rune.Target = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                }
            }
            else if ( item is SkillTeleporter )
            {
                SkillTeleporter tp = (SkillTeleporter)item;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( m_Params[i].StartsWith( "Skill" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Skill = (SkillName)Enum.Parse( typeof( SkillName ), m_Params[i].Substring( ++indexOf ), true );
                    }
                    else if ( m_Params[i].StartsWith( "RequiredFixedPoint" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Required = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) ) * 0.1;
                    }
                    else if ( m_Params[i].StartsWith( "Required" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Required = Utility.ToDouble( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "MessageString" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.MessageString = m_Params[i].Substring( ++indexOf );
                    }
                    else if ( m_Params[i].StartsWith( "MessageNumber" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.MessageNumber = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "PointDest" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "MapDest" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Creatures" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "SourceEffect" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "DestEffect" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "SoundID" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Delay" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                }

                if ( m_ItemID > 0 )
                    item.ItemID = m_ItemID;
            }
            else if ( item is KeywordTeleporter )
            {
                KeywordTeleporter tp = (KeywordTeleporter)item;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( m_Params[i].StartsWith( "Substring" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Substring = m_Params[i].Substring( ++indexOf );
                    }
                    else if ( m_Params[i].StartsWith( "Keyword" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Keyword = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Range" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Range = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "PointDest" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "MapDest" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Creatures" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "SourceEffect" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "DestEffect" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "SoundID" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Delay" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                }

                if ( m_ItemID > 0 )
                    item.ItemID = m_ItemID;
            }
            else if ( item is Teleporter )
            {
                Teleporter tp = (Teleporter)item;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( m_Params[i].StartsWith( "PointDest" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.PointDest = Point3D.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "MapDest" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.MapDest = Map.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Creatures" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Creatures = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "SourceEffect" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.SourceEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "DestEffect" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.DestEffect = Utility.ToBoolean( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "SoundID" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.SoundID = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                    }
                    else if ( m_Params[i].StartsWith( "Delay" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            tp.Delay = TimeSpan.Parse( m_Params[i].Substring( ++indexOf ) );
                    }
                }

                if ( m_ItemID > 0 )
                    item.ItemID = m_ItemID;
            }
            else if ( item is FillableContainer )
            {
                FillableContainer cont = (FillableContainer) item;

                for ( int i = 0; i < m_Params.Length; ++i )
                {
                    if ( m_Params[i].StartsWith( "ContentType" ) )
                    {
                        int indexOf = m_Params[i].IndexOf( '=' );

                        if ( indexOf >= 0 )
                            cont.ContentType = (FillableContentType)Enum.Parse( typeof( FillableContentType ), m_Params[i].Substring( ++indexOf ), true );
                    }
                }

                if ( m_ItemID > 0 )
                    item.ItemID = m_ItemID;
            }
            else if ( m_ItemID > 0 )
            {
                item.ItemID = m_ItemID;
            }

            item.Movable = false;

            for ( int i = 0; i < m_Params.Length; ++i )
            {
                if ( m_Params[i].StartsWith( "Light" ) )
                {
                    int indexOf = m_Params[i].IndexOf( '=' );

                    if ( indexOf >= 0 )
                        item.Light = (LightType)Enum.Parse( typeof( LightType ), m_Params[i].Substring( ++indexOf ), true );
                }
                else if ( m_Params[i].StartsWith( "Hue" ) )
                {
                    int indexOf = m_Params[i].IndexOf( '=' );

                    if ( indexOf >= 0 )
                    {
                        int hue = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );

                        if ( item is DyeTub )
                            ((DyeTub)item).DyedHue = hue;
                        else
                            item.Hue = hue;
                    }
                }
                else if ( m_Params[i].StartsWith( "Name" ) )
                {
                    int indexOf = m_Params[i].IndexOf( '=' );

                    if ( indexOf >= 0 )
                        item.Name = m_Params[i].Substring( ++indexOf );
                }
                else if ( m_Params[i].StartsWith( "Amount" ) )
                {
                    int indexOf = m_Params[i].IndexOf( '=' );

                    if ( indexOf >= 0 )
                    {
                        // Must supress stackable warnings

                        bool wasStackable = item.Stackable;

                        item.Stackable = true;
                        item.Amount = Utility.ToInt32( m_Params[i].Substring( ++indexOf ) );
                        item.Stackable = wasStackable;
                    }
                }
            }

            return item;
        }
示例#53
0
        /// <summary>
        /// Initializes a new instance of the Tower class.
        /// </summary>
        /// <param name="reader">The Content Reader for Castle XML Files</param>
        public Tower(ContentReader reader)
        {
            id = reader.ReadInt32();
              hasCannon = reader.ReadBoolean();
              var position = reader.ReadObject<Vector2>();
              x = (int)position.X;
              y = (int)position.Y;
              height = reader.ReadSingle();
              corners = reader.ReadInt32();
              radius = reader.ReadSingle();
              coverRadius = reader.ReadSingle();
              coverHeight = reader.ReadSingle();
              viewDirection = new Vector3(x, coverHeight + 2, y + 1);

              wallTexture = reader.ReadExternalReference<Texture2D>();
              coverTexture = reader.ReadExternalReference<Texture2D>();

              ////InitTowerGraphics();

              if (HasCannon)
              {
            hasCannon = true;
            cannon = new Cannon(X, coverHeight, Y, null);
              }
        }
示例#54
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
              {
            vb.Dispose();
            vb = null;
            ib.Dispose();
            ib = null;

            if (cannon != null)
            {
              cannon.Dispose();
              cannon = null;
            }

            coverIb.Dispose();
            coverIb = null;
              }
        }
 void Start()
 {
     parent = transform.parent.GetComponent<Cannon>();
 }
示例#56
0
	public Character SpawnCharacter(CharacterData.CharacterClassType classType, int charModeType, int camp, int level, Vector3 pos, Vector3 dir, CharacterStatus.Pose pose){
		this.START_METHOD("SpawnCharacter");
		Character tempChar = null;
		//create the enemies
		if (classType == CharacterData.CharacterClassType.CHARACTER) {
			//create the enemy
			if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.BOWMAN){
				Bowman chara = new Bowman();
				chara.SetPos(pos);
				chara.SetDir(dir);
				chara.SetPose(pose);
				chara.SetCamp(camp);
				chara.SetSpeed(0.01f);
				//set bowman max life
				chara.SetLife(200);
				tempChar = chara;
			} else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.GIANT){
				Gaint chara = new Gaint();
				chara.SetPos(pos);
				chara.SetDir(dir);
				chara.SetPose(pose);
				chara.SetCamp(camp);
				chara.SetSpeed(0.01f);
				//set giant max life
				chara.SetLife(400);
				tempChar = chara;
			} else if((CharacterData.CharacterModel)charModeType == CharacterData.CharacterModel.VIKING){
				Viking chara = new Viking();
				chara.SetPos(pos);
				chara.SetDir(dir);
				chara.SetPose(pose);
				chara.SetCamp(camp);
				chara.SetSpeed(0.01f);
				//set viking max life
				chara.SetLife(300);
				tempChar = chara;
			} 
			if(tempChar != null){
				chars.Add(tempChar);
			} else {
				throw new UnityException("no current char type to spawn!");
			}
		}
		//create the building
		else if (classType == CharacterData.CharacterClassType.BUILDING) {
			//create the barrack to gather resources
			if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.BARRACK){
				TowerBarrack character = new TowerBarrack();
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetCamp(camp);
				tempChar = character;
			} else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.CANNON){
				Cannon character = new Cannon();
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose (pose);
				character.SetCamp(camp);
				//set attack power
				character.SetAttackPower(50);
				tempChar = character;
			}
			//Tower01
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER1){
				Tower1 character = new Tower1();
				character.SetAttackRange(3);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose (pose);
				character.SetCamp(camp);
				character.SetAttackRate(1f);
				//set attack power
				character.SetAttackPower(1);
				tempChar = character;
			}
			//Tower02
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER2){
				Tower2 character = new Tower2();
				character.SetAttackRange(3);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose (pose);
				character.SetCamp(camp);
				character.SetAttackRate(1f);
				//set attack power
				character.SetAttackPower(1);
				tempChar = character;
			}
			//Tower4
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER4){
				Tower4 character = new Tower4();
				character.SetAttackRange(2);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose(pose);
				character.SetCamp(camp);
				tempChar = character;
			}
			//Tower7
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER7){
				Tower7 character = new Tower7();
				character.SetAttackRange(2);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackPower(1);
				character.SetAttackRate(1f);
				tempChar = character;
			}
			//Tower10
			else if((CharacterData.buildingMode)charModeType == CharacterData.buildingMode.TOWER10){
				Tower10 character = new Tower10();
				character.SetAttackRange(4);
				character.SetLevel(1);
				character.SetPos(pos);
				character.SetDir(dir);
				character.SetPose(pose);
				character.SetCamp(camp);
				character.SetAttackPower(1);
				character.SetAttackRate(2f);
				tempChar = character;
			}
			//created the barrack, add to the building list
			if(tempChar != null){
				building.Add(tempChar);
			} else { 
				throw new UnityException("no current building type to spawn!");
			}
		}
		//add to the all character list
		allCharacter.Add (tempChar);
		this.END_METHOD("SpawnCharacter");
		return tempChar;
	}
示例#57
0
 void Awake()
 {
     cannon = GameObject.FindGameObjectWithTag (Tags.cannon).GetComponent<Cannon> ();
     bar = GetComponent<UIProgressBar> ();
     sprite = GetComponent<UISprite> ();
 }
示例#58
0
 void Awake()
 {
     cannon = GameObject.FindGameObjectWithTag (Tags.cannon).GetComponent<Cannon> ();
 }
示例#59
0
    protected override void Start()
    {
        name = "Cannon";
        Instance = this;

        //var meshFilter = GetComponent<MeshFilter>();
        //Mesh = (meshFilter.mesh = new Mesh());
        //RebuildMesh();

        base.Start();
        ray1 = gameObject.FindChild("canon").FindChild("ray1");
        ray2 = gameObject.FindChild("canon").FindChild("ray2");
        bullet = gameObject.FindChild("canon").FindChild("Bullet").FindChild("itm_sphere_invert");

        ray1.renderer.enabled = ray2.renderer.enabled = bullet.renderer.enabled = false;
    }
示例#60
0
 public void Start()
 {
     cannon[0] = new Cannon(transform.Find("LeftCannon"));
     cannon[1] = new Cannon(transform.Find("RightCannon"));
 }