コード例 #1
0
        // todo; use factory
        private static async Task <BatchResult> GetFromGameServerQuery(
            IEnumerable <IPEndPoint> addresses, ServerQueryOptions options, Action <Server> act)
        {
            var q = new ReactiveSource();

            using (var client = q.CreateUdpClient()) {
                return(new BatchResult(await q.ProcessResults(q.GetResults(addresses, client, new QuerySettings {
                    InclPlayers = options.InclPlayers,
                    InclRules = options.InclExtendedDetails
                }))
                                       .Do(x => {
                    var serverInfo = new Server {
                        QueryAddress = x.Address
                    };
                    var r = (SourceParseResult)x.Settings;
                    r.MapTo(serverInfo);
                    serverInfo.Ping = x.Ping;
                    var tags = r.Keywords;
                    if (tags != null)
                    {
                        var p = GameTags.Parse(tags);
                        p.MapTo(serverInfo);
                    }
                    act(serverInfo);
                }).Count()));
            }
        }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (weaponOn)
        {
            vectorPlayer = playerController.transform.position;
            // weaponOnPlayer.transform.LookAt(Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)));

            if (Input.GetMouseButtonDown(0) && Time.time > nextmelee)
            {
                nextmelee = Time.time + meleerate;
                swing     = true;
            }

            if (swing == true && timer > 0)
            {
                //turn on trigger
                GameObject.FindGameObjectWithTag(GameTags.create(GameTags.dissect(gameObject.tag)[0], GameTags.Type.WEAPON, GameTags.WeaponClass.MELEE)).GetComponent <Collider>().enabled = true;
                weaponOnPlayer.transform.RotateAround(vectorPlayer, Vector3.down, Time.deltaTime * smooth);
                timer -= Time.deltaTime;
            }

            else
            {
                swing = false;
                weaponOnPlayer.transform.position = vectorWeaponStart.transform.position;
                weaponOnPlayer.transform.rotation = gameObject.transform.rotation;
                weaponOnPlayer.transform.Rotate(90, 15, 0);
                // disable collider
                GameObject.FindGameObjectWithTag(GameTags.create(GameTags.dissect(gameObject.tag)[0], GameTags.Type.WEAPON, GameTags.WeaponClass.MELEE)).GetComponent <Collider>().enabled = false;
                timer = 0.5f;
            }
        }
    }
コード例 #3
0
    private void OnTriggerEnter(Collider otherCollider)
    {
        GameObject other = otherCollider.gameObject;

        string[] otherTagSections = GameTags.dissect(other.tag);
        if (GameTags.isOnTeam(other.tag) && otherTagSections[0] == tagSections[0] &&
            otherTagSections[1] == GameTags.Type.WAYPOINT &&
            otherTagSections[2] == tagSections[2])
        {
            arrived = true;
        }
        else
        {
            if (arrived || aggresssive)
            {
                if (GameTags.isOnTeam(other.tag) && otherTagSections[0] != tagSections[0] &&
                    (otherTagSections[1] == GameTags.Type.BUILDING ||
                     otherTagSections[1] == GameTags.Type.UNIT ||
                     otherTagSections[1] == GameTags.Type.PLAYER))
                {
                    targetObjet = other.gameObject;
                }
            }
        }
    }
コード例 #4
0
ファイル: Bullet.cs プロジェクト: Kinaetron/FastShooter
        public Bullet(Vector2 position, float speed, GameTags playerTag)
            : base(position)
        {
            BulletDamage   = 3;
            this.playerTag = playerTag;

            if (this.playerTag == GameTags.Player1)
            {
                bullet          = Engine.Instance.Content.Load <Texture2D>("Bullet");
                bulletAnimation = new AnimationData(bullet, 100, 21, false);

                muzzle          = Engine.Instance.Content.Load <Texture2D>("Muzzle");
                muzzleAnimation = new AnimationData(muzzle, 20, 32, false);
            }
            else if (this.playerTag == GameTags.Player2)
            {
                bullet          = Engine.Instance.Content.Load <Texture2D>("Bullet2");
                bulletAnimation = new AnimationData(bullet, 100, 21, false);

                muzzle          = Engine.Instance.Content.Load <Texture2D>("Muzzle2");
                muzzleAnimation = new AnimationData(muzzle, 20, 32, false);
            }

            this.Tag((int)GameTags.Bullet);
            this.Collider = new Hitbox(5, 5, 0.0f, 0.0f);

            this.speed   = speed;
            this.Visible = true;

            sprite = new AnimationPlayer();
            sprite.PlayAnimation(muzzleAnimation);
            flip = SpriteEffects.None;
        }
コード例 #5
0
ファイル: Goldputsch.cs プロジェクト: Wildhaus/Goldputsch
        //Testing TODO List:
        //Find Maximum objects count to turn into constant for GameObjects array initialization, currently capped at 512 for dev
        //Further map out object array structure
        //Code TODO List:
        //TODO: Main Class that initializes the main thread
        //TODO: Object Properties Poker
        //TODO: Tag Properties Poker
        //TODO: LocalPlayer info thread
        //BugFixes TODO List:
        //TODO: doThreadedTagScan runs infinitely, using more resources
        public Goldputsch(GameProcess ElDorado)
        {
            //Initializa game handle
            this.ElDorado = ElDorado;

            //Memory Variables
            TlsAddress = this.ElDorado.TlsAddress;
            objectArrayAddress = getObjectArrayAddress(this.TlsAddress);
            currentTagArrayAddress = ElDorado.Memory.ReadUInt32(TagAddressArrayPointerAddress);
            MAX_TAGS = ElDorado.Memory.ReadUInt16(MaxTagCountAddress);

            //Initialize data structures
            activeObjects = new GameObjects(MAX_OBJECTS, objectArrayAddress);
            activeTags = new GameTags(MAX_TAGS, currentTagArrayAddress);

            //Initialize Encyclopedia
            MetaCache = new Encyclopedia();

            //Initialize controls
            gameCanScan = true;

            //Initialize Threads
            objectScanThread = new Thread(() => { doThreadedObjectScan(); });
            objectScanThread.IsBackground = true;
            objectScanThread.Start();

            tagScanThread = new Thread(() => { doThreadedTagScan(); });
            tagScanThread.IsBackground = true;
            tagScanThread.Start();
        }
コード例 #6
0
ファイル: Player2.cs プロジェクト: Kinaetron/FastShooter
        public Player2(Vector2 position, int playerNo, Color playerColour, GameTags gameTag, Vector2 levelSize)
            : base(position, playerNo, playerColour, gameTag, levelSize)
        {
            lastSignX    = -1;
            playerHealth = 100;

            idleAnimationTop     = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Player/IdleFrameTop2"), 200, 30, true);
            shootingAnimationTop = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Player/ShootFrameTop2"), 200, 34, true);
            dodgeAnimation       = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Player/Dodge2"), 50, 48, true);
            engineAnimation      = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Engine"), 60, 32, true);

            charge1Animation = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Engine"), 100, 32, true);
            charge2Animation = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Engine"), 50, 32, true);

            bottomPlayerIdle  = Engine.Instance.Content.Load <Texture2D>("Player/IdleLegs2");
            bottomPlayerRight = Engine.Instance.Content.Load <Texture2D>("Player/RightLegs2");
            bottomPlayerLeft  = Engine.Instance.Content.Load <Texture2D>("Player/LeftLegs2");

            flip = SpriteEffects.FlipHorizontally;

            sprite.PlayAnimation(idleAnimationTop);
            spriteEngine.PlayAnimation(engineAnimation);

            lastSignX = -1;
            xLast     = true;

            healthRectangle = new Rectangle(0, 0, healthRectangle.Right + (int)playerHealth, 32);

            healthBarPosition     = new Vector2(520, 25);
            healthBarInitPosition = healthBarPosition;
        }
コード例 #7
0
ファイル: Player.cs プロジェクト: Kinaetron/FastShooter
        public Player(Vector2 position, int playerNo, Color playerColour, GameTags gameTag, Vector2 levelSize)
            : base(position)
        {
            sprite       = new AnimationPlayer();
            spriteEngine = new AnimationPlayer();
            chargeAni    = new AnimationPlayer();

            this.levelSize    = levelSize;
            this.playerNo     = playerNo;
            this.PlayerColour = playerColour;
            assignColour      = playerColour;

            Tag((int)gameTag);
            playerTag    = gameTag;
            Collider     = new Hitbox((float)32.0f, (float)33.0f, 0.0f, 0.0f);
            this.Visible = true;

            healthBarImageEmpty = Engine.Instance.Content.Load <Texture2D>("GUI/EmptyHealthBar");
            healthBarImage1     = Engine.Instance.Content.Load <Texture2D>("GUI/HealthBar1");
            healthBarImage2     = Engine.Instance.Content.Load <Texture2D>("GUI/HealthBar2");

            hitAnimationTop = new AnimationData(Engine.Instance.Content.Load <Texture2D>("Player/HitFrameTop"), 200, 30, true);
            bottomPlayerHit = Engine.Instance.Content.Load <Texture2D>("Player/HitLegs");

            engineSound             = Engine.Instance.Content.Load <SoundEffect>("EngineSound");
            engineInstance          = engineSound.CreateInstance();
            engineInstance.IsLooped = true;

            shootLevel1    = Engine.Instance.Content.Load <SoundEffect>("ShootLevel1");
            shootInstance1 = shootLevel1.CreateInstance();

            shootLevel2    = Engine.Instance.Content.Load <SoundEffect>("ShootLevel2");
            shootInstance2 = shootLevel2.CreateInstance();

            shootLevel3    = Engine.Instance.Content.Load <SoundEffect>("ShootLevel3");
            shootInstance3 = shootLevel3.CreateInstance();

            chargeSound             = Engine.Instance.Content.Load <SoundEffect>("chargeSound");
            chargeInstance          = chargeSound.CreateInstance();
            chargeInstance.IsLooped = true;

            chargeSound2             = Engine.Instance.Content.Load <SoundEffect>("chargeSound2");
            chargeInstance2          = chargeSound2.CreateInstance();
            chargeInstance2.IsLooped = true;

            dodgeSound    = Engine.Instance.Content.Load <SoundEffect>("dodgeSound");
            dodgeInstance = dodgeSound.CreateInstance();

            hurtSound    = Engine.Instance.Content.Load <SoundEffect>("hurtsound");
            hurtInstance = hurtSound.CreateInstance();


            this.Add(counters);
        }
コード例 #8
0
    private void CmdmoveWaypoint(string unitClass, bool aggressive)
    {
        Debug.LogFormat("Moving waypoint {0} {1}", team, unitClass);
        Vector3 newPos;

        if (didClick(out newPos))
        {
            string     waypointTag = GameTags.create(team, GameTags.Type.WAYPOINT, unitClass);
            GameObject waypoint    = GameObject.FindGameObjectWithTag(waypointTag);
            waypoint.transform.position = newPos;
        }
        // TODO: set aggressive or not
    }
コード例 #9
0
        private static async Task UpdateServerInfo(ArmaServerInfoModel s, SteamApi api, bool inclRules)
        {
            s.GameTags = s.Tags == null ? null : GameTags.Parse(s.Tags);
            if (inclRules)
            {
                var rules = await api.GetServerRules(s.QueryEndPoint).ConfigureAwait(false);

                var mods = SourceQueryParser.GetList(rules, "modNames");
                s.SignatureList = SourceQueryParser.GetList(rules, "sigNames").ToHashSet();
                s.ModList       = mods.Select(x => new ServerModInfo {
                    Name = x
                }).ToList();
            }
        }
コード例 #10
0
    private void CmdspawnBuilding(GameObject building)
    {
        GameObject clickedObject;

        if (didClickObject(out clickedObject))
        {
            string[] tagSections = GameTags.dissect(clickedObject.tag);
            Debug.LogFormat("team: {0} tags: {1}", team, tagSections);
            if (GameTags.isOnTeam(clickedObject.tag) && tagSections[0] == team && tagSections[1] == GameTags.Type.PLACEHOLDER)
            {
                clickedObject.GetComponent <BuildingPlot>().CmdspawnBuilding(building);
                Debug.Log("spawning building");
            }
        }
    }
コード例 #11
0
    public void CmdspawnUnit()
    {
        string     newTag = GameTags.create(GameTags.dissect(gameObject.tag)[0], GameTags.Type.PLAYER);
        GameObject player = GameObject.FindGameObjectWithTag(newTag);

        for (int i = 0; i < MAX_UNITS; ++i)
        {
            if (spawnedUnits[i] == null)
            {
                spawnedUnits[i] = Instantiate(unitPrefab, gameObject.transform.GetChild(0).transform.position, Quaternion.identity) as GameObject;
                // NetworkServer.SpawnWithClientAuthority(spawnedUnits[i],player);
                NetworkServer.Spawn(spawnedUnits[i]);
                break;
            }
        }
    }
コード例 #12
0
 public ArmaServerProfile()
 {
     CreateMap <ArmaServerInfo, ArmaServerInfoModel>();
     CreateMap <ServerModInfo, GameServerQuery.Games.RV.ServerModInfo>();
     CreateMap <SourceParseResult, ArmaServerInfoModel>()
     .ConstructUsing((src) => new ArmaServerInfoModel(src.Address))
     .ForMember(x => x.ConnectionEndPoint, opt =>
                opt.MapFrom(
                    src => new IPEndPoint(src.Address.Address, src.Port > 0 ? src.Port : src.Address.Port - 1)))
     .ForMember(x => x.Mission, opt => opt.MapFrom(src => src.Game))
     //.ForMember(x => x.IsDedicated, opt => opt.MapFrom(src => src.ServerType > 0))
     .ForMember(x => x.Tags, opt => opt.MapFrom(src => src.Keywords))
     .ForMember(x => x.RequirePassword, opt => opt.MapFrom(src => src.Visibility > 0))
     .ForMember(x => x.IsVacEnabled, opt => opt.MapFrom(src => src.Vac > 0))
     .ForMember(x => x.GameTags,
                opt => opt.MapFrom(src => src.Keywords == null ? null : GameTags.Parse(src.Keywords)));
 }
コード例 #13
0
    public void CmdspawnBuilding(GameObject building)
    {
        if (!active)
        {
            string     newTag = GameTags.create(GameTags.dissect(gameObject.tag)[0], GameTags.Type.PLAYER);
            GameObject player = GameObject.FindGameObjectWithTag(newTag);

            Quaternion buildingRotation = Quaternion.identity;
            this.building = (GameObject)Instantiate(building, gameObject.transform.position, buildingRotation);
            if (GameTags.dissect(gameObject.tag)[0] == GameTags.Team.RED)
            {
                this.building.transform.Rotate(0, 180, 0);
            }
            // NetworkServer.SpawnWithClientAuthority(this.building, player);
            NetworkServer.Spawn(this.building);
            active = true;
        }
    }
コード例 #14
0
    // Update is called once per frame
    void Update()
    {
        if (playerStats.inTerritoryMode)
        {
            // Camera Speed
            if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
            {
                speed = fasterer;
            }
            else if (Input.GetKeyUp(KeyCode.LeftShift) || Input.GetKeyUp(KeyCode.RightShift))
            {
                speed = normal;
            }

            //Camera Movement
            if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
            {
                tdCam.transform.Translate(new Vector3(speed * Time.deltaTime, 0, 0));
            }
            if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
            {
                tdCam.transform.Translate(new Vector3(-speed * Time.deltaTime, 0, 0));
            }
            if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
            {
                tdCam.transform.Translate(new Vector3(0, -speed * Time.deltaTime, 0));
            }
            if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
            {
                tdCam.transform.Translate(new Vector3(0, speed * Time.deltaTime, 0));
            }
            //Camera Zoom
            float fov = tdCamScript.fieldOfView;
            fov -= Input.GetAxis("Mouse ScrollWheel") * zspeed;
            fov  = Mathf.Clamp(fov, zmin, zmax);
            tdCamScript.fieldOfView  = fov;
            tdCam.transform.rotation = Quaternion.identity;
            tdCam.transform.Rotate(90, 0, 0);
            if (GameTags.dissect(gameObject.tag)[0] == GameTags.Team.RED)
            {
                tdCam.transform.Rotate(0, 0, 180);
            }
        }
    }
コード例 #15
0
ファイル: AMProfile.cs プロジェクト: dkv01/withSIX.Desktop
 public AMProfile()
 {
     CreateMap <SourceParseResult, Server>()
     .Include <SourceParseResult, ArmaServer>()
     .Include <SourceParseResult, ArmaServerWithPlayers>()
     .SourceParseResultToServer();
     CreateMap <SourceParseResult, ArmaServer>()
     .Include <SourceParseResult, ArmaServerWithPlayers>()
     .SourceParseResultToServer()
     .AfterMap((src, dest) => {
         var tags = src.Keywords;
         if (tags != null)
         {
             var p = GameTags.Parse(tags);
             p.MapTo(dest);
         }
     });
     CreateMap <SourceParseResult, ArmaServerWithPlayers>();
 }
コード例 #16
0
 public static ArmaServerInfo FromWrap(int serverIndex, GameServerItemWrap serverData)
 {
     try {
         return(new ArmaServerInfo(serverIndex, new ServerKey(serverData.IP, serverData.QueryPort))
         {
             ConnectionEndPoint = new ServerKey(serverData.IP, serverData.ConnectionPort).ToIpEndpoint(),
             Name = serverData.Name,
             Map = serverData.Map,
             Mission = serverData.Description,
             ServerVersion = serverData.ServerVersion,
             RequirePassword = serverData.RequirePassword,
             IsVacEnabled = serverData.IsVACSecure,
             CurrentPlayers = serverData.Players,
             MaxPlayers = serverData.MaxPlayers,
             Ping = serverData.Ping,
             Tags = serverData.Tags,
             GameTags = GameTags.Parse(serverData.Tags)
         });
     } catch {
         return(new ArmaServerInfo(serverIndex, new ServerKey(serverData.IP, serverData.QueryPort)));
     }
 }
コード例 #17
0
 // Update is called once per frame
 void Update()
 {
     if (!isOnTeam)
     {
         isOnTeam = GameTags.isOnTeam(gameObject.tag);
         if (isOnTeam)
         {
             tagSections    = GameTags.dissect(gameObject.tag);
             targetWaypoint = GameObject.FindGameObjectWithTag(GameTags.create(tagSections[0], GameTags.Type.WAYPOINT, tagSections[2]));
             Debug.LogFormat("Unit {0} has waypoint {1}", gameObject.tag, targetWaypoint.tag);
             if (targetWaypoint != null)
             {
                 controller.SetTarget(targetWaypoint.transform);
             }
         }
     }
     else
     {
         if (tagSections == null)
         {
             tagSections = GameTags.dissect(gameObject.tag);
         }
         if (arrived && targetObjet == null)
         {
             controller.SetTarget(gameObject.transform);
         }
         else if (targetObjet != null)
         {
             controller.SetTarget(targetObjet.transform);
         }
         else
         {
             controller.SetTarget(targetWaypoint.transform);
         }
     }
 }
コード例 #18
0
 public static bool IsEqual(string objectTag, GameTags gameTag)
 {
     return(objectTag.Equals(gameTag.ToString()));
 }
コード例 #19
0
    // Update is called once per frame
    void Update()
    {
        if (!isOnTeam)
        {
            isOnTeam = GameTags.isOnTeam(gameObject.tag);
            if (isOnTeam)
            {
                team = GameTags.dissect(gameObject.tag)[0];
            }
        }
        else
        {
            if (playerStats.inTerritoryMode)
            {
                if (Input.GetKeyDown(KeyCode.Alpha0))
                {
                    mouseState = MouseState.EMPTY;
                    Debug.Log("set mouse to empty");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    mouseState = MouseState.ATTACK_WAYPOINT;
                    Debug.Log("set mouse to attack waypoint");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    mouseState = MouseState.DEFENSE_WAYPOINT;
                    Debug.Log("set mouse to defense waypoint");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    mouseState = MouseState.SUPPORT_WAYPOINT;
                    Debug.Log("set mouse to support waypoint");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    mouseState = MouseState.SCOUT__WAYPOINT;
                    Debug.Log("set mouse to scout waypoint");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha5))
                {
                    mouseState = MouseState.SPAWN_ATTACK;
                    Debug.Log("set mouse to attack building");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha6))
                {
                    mouseState = MouseState.SPAWN_DEFENSE;
                    Debug.Log("set mouse to defense building");
                }
                else if (Input.GetKeyDown(KeyCode.Alpha7))
                {
                    mouseState = MouseState.SPAWN_SUPPORT;
                    Debug.Log("set mouse to support building");
                }

                //if (Input.GetMouseButtonDown(0)) {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    Debug.Log("clicked mouse button");
                    bool aggressive = Input.GetKey(KeyCode.LeftShift);
                    if (aggressive)
                    {
                        Debug.Log("set aggressive");
                    }
                    switch (mouseState)
                    {
                    case MouseState.EMPTY: {
                        // spawn units when clicking on a building
                        // if 0 == team
                        // if 1 == building
                        // if 2 == spawn or HQ
                        // call spawn
                        GameObject clickedObject;
                        if (didClickObject(out clickedObject))
                        {
                            Debug.LogFormat("clicked on obj {0} with tag {1}", clickedObject.name,
                                            clickedObject.tag);
                            string[] tagSections = GameTags.dissect(clickedObject.tag);
                            if (GameTags.isOnTeam(clickedObject.tag) && tagSections[0] == team && tagSections[1] == GameTags.Type.BUILDING &&
                                (tagSections[2] == GameTags.BuildingClass.SPAWN || tagSections[2] == GameTags.BuildingClass.HQ))
                            {
                                // TODO: check for resources here
                                Debug.Log("Spawning units");
                                clickedObject.GetComponent <UnitSpawner>().CmdspawnUnit();
                            }
                        }
                        break;
                    }

                    case MouseState.ATTACK_WAYPOINT: {
                        // set waypoint for attack units
                        CmdmoveWaypoint(GameTags.UnitClass.ATTACK, aggressive);
                        Debug.Log("Set attack waypoint");
                        break;
                    }

                    case MouseState.DEFENSE_WAYPOINT: {
                        // set waypoint for defense units
                        CmdmoveWaypoint(GameTags.UnitClass.DEFENSE, aggressive);
                        Debug.Log("Set defense waypoint");
                        break;
                    }

                    case MouseState.SUPPORT_WAYPOINT: {
                        // set waypoint for support units
                        CmdmoveWaypoint(GameTags.UnitClass.SUPPORT, aggressive);
                        Debug.Log("Set support waypoint");
                        break;
                    }

                    case MouseState.SCOUT__WAYPOINT: {
                        // set waypoint for scout units
                        CmdmoveWaypoint(GameTags.UnitClass.SCOUT, aggressive);
                        Debug.Log("Set scout waypoint");
                        break;
                    }

                    case MouseState.SPAWN_ATTACK: {
                        // spawn an attack building
                        if (team == GameTags.Team.RED)
                        {
                            CmdspawnBuilding(redAttackBuildingPrefab);
                            Debug.Log("Spawn red attack building");
                        }
                        else
                        {
                            CmdspawnBuilding(blueAttackBuildingPrefab);
                            Debug.Log("Spawn blue attack building");
                        }
                        break;
                    }

                    case MouseState.SPAWN_DEFENSE: {
                        // spawn an attack building
                        if (team == GameTags.Team.RED)
                        {
                            CmdspawnBuilding(redDefenseBuildingPrefab);
                            Debug.Log("Spawn red defense building");
                        }
                        else
                        {
                            CmdspawnBuilding(blueDefenseBuildingPrefab);
                            Debug.Log("Spawn blue defense building");
                        }
                        break;
                    }

                    case MouseState.SPAWN_SUPPORT: {
                        // spawn an attack building
                        if (team == GameTags.Team.RED)
                        {
                            CmdspawnBuilding(redSupportBuildingPrefab);
                            Debug.Log("Spawn red support building");
                        }
                        else
                        {
                            CmdspawnBuilding(blueSupportBuildingPrefab);
                            Debug.Log("Spawn blue support building");
                        }
                        break;
                    }
                    }
                }
            }
            else
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    switch (mouseState)
                    {
                    case MouseState.ATTACK_WAYPOINT: {
                        // set waypoint for attack units
                        CmdmoveWaypoint(GameTags.UnitClass.ATTACK, true);
                        break;
                    }

                    case MouseState.DEFENSE_WAYPOINT: {
                        // set waypoint for defense units
                        CmdmoveWaypoint(GameTags.UnitClass.DEFENSE, true);
                        break;
                    }

                    case MouseState.SUPPORT_WAYPOINT: {
                        // set waypoint for support units
                        CmdmoveWaypoint(GameTags.UnitClass.SUPPORT, true);
                        break;
                    }

                    case MouseState.SCOUT__WAYPOINT: {
                        // set waypoint for scout units
                        CmdmoveWaypoint(GameTags.UnitClass.SCOUT, true);
                        break;
                    }
                    }
                }
            }
        }
    }
コード例 #20
0
    // Update is called once per frame
    void Update()
    {
        if (!playersConnected)
        {
            redPlayer        = GameObject.FindWithTag("RED_PLAYER");
            bluePlayer       = GameObject.FindWithTag("BLUE_PLAYER");
            playersConnected = redPlayer != null && bluePlayer != null;

            //Debug.Log("trying to find all players");
        }
        if (playersConnected)
        {
            if (!setBuildings)
            {
                Debug.Log("Updating buildings");
                foreach (NetworkConnection conn in NetworkServer.connections)
                {
                    Debug.LogFormat("current connection: {0}", conn);
                    if (conn.hostId != -1)
                    {
                        Debug.Log("Not the host :3");
                        foreach (GameObject building in GameObject.FindGameObjectsWithTag(GameTags.create(GameTags.Team.BLUE, GameTags.Type.PLACEHOLDER, GameTags.Type.BUILDING)))
                        {
                            Debug.LogFormat("setting authority for building {0}", building);
                            Debug.LogFormat("current building authority: {0}", building.GetComponent <NetworkIdentity>().clientAuthorityOwner);
                            building.GetComponent <NetworkIdentity>().AssignClientAuthority(conn);
                            Debug.LogFormat("new building authority: {0}", building.GetComponent <NetworkIdentity>().clientAuthorityOwner);
                        }
                    }
                }
                setBuildings = true;
            }
            //checking if the hq and building of one player is destroyed
            if (redPlayer == null)
            {
                //making the local host winner
                blueWin = true;
                redWin  = false;
                changeScene();
            }
            else if (bluePlayer == null)
            {
                //makeing the other player winner

                blueWin = false;
                redWin  = true;
                changeScene();
            }
        }

        // redHQ = GameObject.FindWithTag("RED_BUILDING_HQ");
        // blueHQ = GameObject.FindWithTag("BLUE_BUILDING_HQ");
    }