Exemplo n.º 1
0
    public void setNumbers(NetworkViewID player, string Uname, string Pword, int Number)
    {
        NetworkView playerN = NetworkView.Find(player);

        playerN.GetComponent <playerController>().activeAccount = new Account(Uname, Pword);
        playerN.GetComponent <playerController>().playerNumber  = Number;
        if (BasicFunctions.ForkModus)
        {
            switch (Number)
            {
            case 1:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player1F);
                break;

            case 2:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player2F);
                break;

            case 3:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player3F);
                break;

            case 4:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player4F);
                break;

            default:
                Debug.Log("DIKKE TERROR ERROR");
                break;
            }
        }
        else
        {
            switch (Number)
            {
            case 1:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player1R);
                break;

            case 2:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player2R);
                break;

            case 3:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player3R);
                break;

            case 4:
                playerN.transform.Find("Circle").renderer.material.SetTexture("_MainTex", Player4R);
                break;

            default:
                Debug.Log("DIKKE TERROR ERROR");
                break;
            }
        }
    }
    [RPC] void SummonCreature(NetworkViewID viewID, int cretID, NetworkViewID vid2, bool isHero, int player)
    {
        Network.Destroy(vid2);
        NetworkView    nv = NetworkView.Find(viewID);
        CreatureScript cs = nv.GetComponent <CreatureScript>();

        print(cretID);
        cs.playerID = this.playerID;
        if (isHero)
        {
            TurnManager.instance.heroObjects[this.playerID] = cs;
            cs.playerID = this.playerID;
        }
        else
        {
            cs.attack      = CardDatabase.instance.cards[cretID].statA;
            cs.health      = cs.maxhealth = CardDatabase.instance.cards[cretID].statB;
            cs.cardTex     = CardDatabase.instance.cards[cretID].cardPicture;
            cs.name        = CardDatabase.instance.cards[cretID].name;
            cs.description = CardDatabase.instance.cards[cretID].descrip;
            cs.type        = CardDatabase.instance.cards[cretID].type;
            cs.flavor      = CardDatabase.instance.cards[cretID].flavor;
            cs.canAttack   = CardDatabase.instance.cards[cretID].boolA;
            cs.playerID    = this.playerID;
            cs.attacked    = CardDatabase.instance.cards[cretID].boolB;
            string desc = CardDatabase.instance.cards[cretID].descrip.Replace("\\n", "\n");
            cs.description = desc;
            string flav = CardDatabase.instance.cards[cretID].flavor.Replace("\\n", "\n");
            cs.flavor      = flav;
            cs.summonSound = CardDatabase.instance.cards[cretID].soundA;
            cs.attackSound = CardDatabase.instance.cards[cretID].soundB;
            cs.dieSound    = CardDatabase.instance.cards[cretID].soundC;
        }
    }
Exemplo n.º 3
0
    private NetworkView Create(ref CustomInstantiationArgs args, out IDMain instance)
    {
        NetworkView view3;

        if ((float.IsNaN(args.position.x) || float.IsNaN(args.position.y)) || float.IsNaN(args.position.z))
        {
            Debug.LogWarning("NetMainPrefab -> Create -  args.position = " + args.position);
            Debug.LogWarning("This means you're creating an object with a bad position!");
        }
        NetInstance instance2 = _currentNetInstance;

        try
        {
            _currentNetInstance = null;
            if (args.hasCustomInstantiator)
            {
                NetworkView networkView;
                instance = null;
                try
                {
                    instance = args.customInstantiate.CustomInstantiatePrefab(ref args);
                }
                catch (Exception exception)
                {
                    Debug.LogError(string.Format("Thrown Exception during custom instantiate via '{0}' with instantiation '{2}'\r\ndefault instantiation will now occur --  exception follows..\r\n{1}", args.customInstantiate, exception, this), this);
                    if (instance != null)
                    {
                        Object.Destroy(instance);
                    }
                    instance = null;
                }
                try
                {
                    networkView = instance.networkView;
                    if (networkView == null)
                    {
                        Debug.LogWarning(string.Format("The custom instantiator '{0}' with instantiation '{1}' did not return a idmain with a network view. so its being added", args.customInstantiate, this), this);
                        networkView = instance.gameObject.AddComponent <uLinkNetworkView>();
                    }
                }
                catch (Exception exception2)
                {
                    networkView = null;
                    Debug.LogError(string.Format("The custom instantiator '{0}' did not instantiate a IDMain with a networkview or something else with instantiation '{2}'.. \r\n {1}", args.customInstantiate, exception2, this), this);
                }
                if (networkView != null)
                {
                    return(networkView);
                }
            }
            NetworkView view2 = (NetworkView)NetworkInstantiatorUtility.Instantiate(args.prefabNetworkView, args.args);
            instance = view2.GetComponent <IDMain>();
            view3    = view2;
        }
        finally
        {
            _currentNetInstance = instance2;
        }
        return(view3);
    }
Exemplo n.º 4
0
    void OnTriggerStay(Collider coll)
    {
        if (coll.tag == "Player")
        {
           // GameObject hitPlayer = coll.gameObject;

            nView = coll.GetComponent<NetworkView>();

            nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 1);

        }
        if (coll.tag == "Boss")
        {
            // GameObject hitPlayer = coll.gameObject;
            nView = coll.GetComponent<NetworkView>();
            nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 1);

            if (nView.isMine)
            {
                Sentry companion;
                companion = nView.GetComponent<Sentry>();
                companion.ClientTakeDamageFromWeapon(1);
            }
            else
            {
                nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 1);
            }
        }
    }
Exemplo n.º 5
0
    void RPCInit(NetworkViewID tgt, int velocity)
    {
        NetworkView view = NetworkView.Find(tgt);

        target      = (view == null)? null :view.GetComponent <Alien>();
        speed       = velocity;
        initialized = true;
    }
 public static bool Prefix(NetworkView __instance, string name, RPCMode mode, ref object[] args)
 {
     if (Assembly.GetCallingAssembly().Equals(typeof(GameScript).Assembly))
     {
         switch (name)
         {
         case "Set":
             if (args.Length == 3)
             {
                 if (args[0] is int)
                 {
                     if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                     {
                         InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                         return(true);
                     }
                     GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref args[0]);
                 }
             }
             else if (args.Length == 1)
             {
                 if (args[0] is int[] arr && arr.Length == 2)
                 {
                     if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                     {
                         InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                         return(true);
                     }
                     ItemStandScript itemStandScript = __instance.GetComponent <ItemStandScript>();
                     if (itemStandScript == null || !itemStandScript.isChipStand)
                     {
                         args[0] = new int[]
                         {
                             GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, arr[0]),
                             arr[1],
                         };
                     }
                     else
                     {
                         args[0] = new int[]
                         {
                             GadgetNetwork.ConvertIDToHost(ChipRegistry.Singleton, arr[0]),
                             arr[1],
                         };
                     }
                 }
                 else if (args[0] is Package2 pack2)
                 {
                     if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                     {
                         InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                         return(true);
                     }
                     GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref pack2.id);
                 }
             }
             break;
Exemplo n.º 7
0
    [RPC] void AttackOther(NetworkViewID nvid)
    {
        NetworkView    nv = NetworkView.Find(nvid);
        CreatureScript cs = nv.GetComponent <CreatureScript>();

        if (networkView.isMine)
        {
            networkView.RPC("PlaySound", RPCMode.All, 1);
            networkView.RPC("TakeDamage", RPCMode.All, cs.attack);
            nv.RPC("TakeDamage", RPCMode.All, attack);
        }
    }
Exemplo n.º 8
0
    protected void Client_OnKilledBy(NetworkViewID attackerViewID, NetworkMessageInfo info)
    {
        NetworkView view = NetworkView.Find(attackerViewID);

        if (view == null)
        {
            this.Client_OnKilledShared(false, null, ref info);
        }
        else
        {
            Character component = view.GetComponent <Character>();
            this.Client_OnKilledShared((bool)component, component, ref info);
        }
    }
Exemplo n.º 9
0
    protected void _Destroyer(NetworkView networkView)
    {
        NetInstance instance = _currentNetInstance;

        try
        {
            NetInstance component = networkView.GetComponent <NetInstance>();
            _currentNetInstance = component;
            if (component != null)
            {
                component.zzz___onpredestroy();
            }
            Object.Destroy(networkView.gameObject);
        }
        finally
        {
            _currentNetInstance = instance;
        }
    }
Exemplo n.º 10
0
    [RPC] void AttackOther(NetworkViewID nvid)
    {
        NetworkView    nv = NetworkView.Find(nvid);
        CreatureScript cs = nv.GetComponent <CreatureScript>();

        if (networkView.isMine)
        {
            networkView.RPC("PlaySound", RPCMode.All, 1);
            if (!CardDatabase.instance.cards[this.cardID].abilities.Contains(CardType.CardAbilities.Ranged))
            {
                networkView.RPC("TakeDamage", RPCMode.All, cs.attack);
            }
            nv.RPC("TakeDamage", RPCMode.All, attack);
        }
        if (CardDatabase.instance.cards[this.cardID].abilities.Contains(CardType.CardAbilities.Airborne))
        {
            attackedAirborne = true;
        }
    }
Exemplo n.º 11
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (toInitialize)
        {
            toInitialize = false;
            swapTowerSkin();
        }
        Alien closestEnemy;

        if (GameSession.Instance.isDefender)
        {
            if ((closestEnemy = EnemyInRange()) != null)
            {
                Vector3 lookDir = closestEnemy.transform.position - transform.position;
                lookDir -= new Vector3(0, lookDir.y, 0);
                Quaternion targetRotation = Quaternion.LookRotation(lookDir);
                transform.parent.rotation = Quaternion.RotateTowards(transform.parent.rotation, targetRotation, Time.deltaTime * rotationSpeed);
            }
        }
        else if (GameSession.Instance.isNetworkGame)
        {
            TowerWrapper tower = transform.parent.GetComponent <TowerWrapper>();
            if (tower != null && tower.targetView != NetworkViewID.unassigned)
            {
                NetworkView view = NetworkView.Find(tower.targetView);
                if (view == null)                 // enemy has dieded
                {
                    return;
                }
                closestEnemy = (Alien)view.GetComponent <Alien>();
                Vector3 lookDir = closestEnemy.transform.position - transform.position;
                lookDir -= new Vector3(0, lookDir.y, 0);
                Quaternion targetRotation = Quaternion.LookRotation(lookDir);
                transform.parent.rotation = Quaternion.RotateTowards(transform.parent.rotation, targetRotation, Time.deltaTime * rotationSpeed);
            }
            if (tower != null && Level != tower.Level)
            {
                Level = tower.Level;
                swapTowerSkin();
            }
        }
    }
Exemplo n.º 12
0
    protected void SMSet(NetworkViewID masterViewID)
    {
        NetworkView context = NetworkView.Find(masterViewID);

        if (context != null)
        {
            StructureMaster component = context.GetComponent <StructureMaster>();
            if (component != null)
            {
                component.AppendStructureComponent(this);
            }
            else
            {
                Debug.LogWarning("No Master On GO", context);
            }
        }
        else
        {
            Debug.LogWarning("Couldnt find master view", this);
        }
    }
Exemplo n.º 13
0
	// アイテム取得処理.
	void GetItemOnNetwork(NetworkViewID viewId)
	{
		// 拾われたフラグ.
		if (isPickedUp)
			return;
		isPickedUp = true;

		// 拾ったPlayerを探す.
		NetworkView player =  NetworkView.Find(viewId);
		if (player == null)
			return;

		// 拾ったPlayerにアイテムを与える.
		if (player.isMine)
			player.SendMessage("GetItem",kind);
		else 
			player.GetComponent<NetworkView>().RPC("GetItem",player.owner,kind);


		Network.Destroy(gameObject);
		Network.RemoveRPCs(GetComponent<NetworkView>().viewID);
	}
Exemplo n.º 14
0
        public static bool Prefix(NetworkView __instance, string name, RPCMode mode, ref object[] args)
        {
            if (Assembly.GetCallingAssembly().Equals(typeof(GameScript).Assembly))
            {
                switch (name)
                {
                case "Set":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref args[0]);
                        }
                    }
                    else if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 2)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            ItemStandScript itemStandScript = __instance.GetComponent <ItemStandScript>();
                            if (itemStandScript == null || !itemStandScript.isChipStand)
                            {
                                GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[0]);
                            }
                            else
                            {
                                GadgetNetwork.ConvertIDToHost(ChipRegistry.Singleton, ref (args[0] as int[])[0]);
                            }
                        }
                        else if (args[0] is Package2)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref (args[0] as Package2).id);
                        }
                    }
                    break;

                case "UA":
                    if (args.Length == 3)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 8)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[1]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[2]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[3]);
                            GadgetNetwork.ConvertIDToHost(null /* RaceRegistry */, ref (args[0] as int[])[4]);
                            GadgetNetwork.ConvertIDToHost(null /* UniformRegistry */, ref (args[0] as int[])[6]);
                            GadgetNetwork.ConvertIDToHost(null /* AugmentRegistry */, ref (args[0] as int[])[7]);
                        }
                    }
                    else if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 3)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[1]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[2]);
                        }
                    }
                    break;

                case "ShootProjectile":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "CreateWorld":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length > 1)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref (args[0] as int[])[0]);
                            for (int i = 1; i < (args[0] as int[]).Length; i++)
                            {
                                GadgetNetwork.ConvertIDToHost(TileRegistry.Singleton, ref (args[0] as int[])[i]);
                            }
                        }
                    }
                    break;

                case "CreateTown":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length == 2)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref (args[0] as int[])[0]);
                        }
                    }
                    break;

                case "SpawnProjectile":
                    if (args.Length == 4)
                    {
                        if (args[1] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[1]);
                        }
                    }
                    break;

                case "SetNetworked":
                    if (args.Length == 3)
                    {
                        if (args[1] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[1]);
                        }
                    }
                    break;

                case "SetName":
                    if (args.Length == 1)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref args[0]);
                        }
                    }
                    break;

                case "Staff":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "ShootSpecial":
                    if (args.Length == 3)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "ShootProjectile2":
                    if (args.Length == 4)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "NetworkedProjectile":
                    if (args.Length == 4)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton /* ProjectileRegistry */, ref args[0]);
                        }
                    }
                    break;

                case "Init":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length >= 11)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[5]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[6]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[7]);
                        }
                    }
                    break;

                case "Chip":
                    if (args.Length == 1)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ChipRegistry.Singleton, ref args[0]);
                        }
                    }
                    break;

                case "SpawnItem":
                    if (args.Length == 2)
                    {
                        if (args[0] is int[] && (args[0] as int[]).Length >= 11)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[0]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[5]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[6]);
                            GadgetNetwork.ConvertIDToHost(ItemRegistry.Singleton, ref (args[0] as int[])[7]);
                        }
                    }
                    break;

                case "ChangePortal":
                    if (args.Length == 2)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref args[0]);
                        }
                    }
                    break;

                case "ChangePortal2":
                    if (args.Length == 2)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref args[0]);
                        }
                    }
                    break;

                case "RefreshWall":
                    if (args.Length == 1)
                    {
                        if (args[0] is int[] arr)
                        {
                            for (int i = 0; i < arr.Length; i++)
                            {
                                if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                                {
                                    InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                    return(false);
                                }
                                GadgetNetwork.ConvertIDToHost(TileRegistry.Singleton, ref arr[i]);
                            }
                        }
                    }
                    break;

                case "RefreshShip":
                    if (args.Length == 2)
                    {
                        if (args[0] is int[] arr1 && args[1] is int[] arr2)
                        {
                            for (int i = 0; i < arr1.Length; i++)
                            {
                                if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                                {
                                    InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                    return(false);
                                }
                                GadgetNetwork.ConvertIDToHost(TileRegistry.Singleton, ref arr1[i]);
                            }
                            for (int i = 0; i < (arr2 as int[]).Length; i++)
                            {
                                if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                                {
                                    InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                    return(false);
                                }
                                GadgetNetwork.ConvertIDToHost(TileRegistry.Singleton, ref arr2[i]);
                            }
                        }
                    }
                    break;

                case "SetMaterial":
                    if (args.Length == 1)
                    {
                        if (args[0] is int)
                        {
                            if (!GadgetNetwork.MatrixReady && GadgetNetwork.GetTimeSinceConnect() < GadgetNetwork.MatrixTimeout)
                            {
                                InstanceTracker.GameScript.StartCoroutine(GadgetUtils.WaitAndInvoke(RPCMethod, GadgetNetwork.MatrixTimeout - GadgetNetwork.GetTimeSinceConnect(), () => GadgetNetwork.MatrixReady, __instance, name, mode, args));
                                return(false);
                            }
                            GadgetNetwork.ConvertIDToHost(PlanetRegistry.Singleton, ref args[0]);
                        }
                    }
                    break;
                }
            }
            return(true);
        }
 /// <summary>
 /// Calls GetComponent on the object that we are referencing.
 /// </summary>
 /// <typeparam name="T">Type of the component that we want to get.</typeparam>
 /// <returns>The component if found, otherwise null</returns>
 public T GetComponent <T>() where T : Component
 {
     return(exists ? _networkView.GetComponent <T>() : null);
 }
Exemplo n.º 16
0
    void DoStuff()
    {
        Ray ray = new Ray(transform.parent.GetComponent<Camera>().transform.position, transform.parent.GetComponent<Camera>().transform.forward);
        Vector3 pos = transform.parent.GetComponent<Camera>().transform.position;
        Vector3 dir = transform.parent.GetComponent<Camera>().transform.forward;

        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            weapon = 0;
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            weapon = 1;
        }
        if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            weapon = 2;
        }
        if (Input.GetKeyDown(KeyCode.Alpha4))
        {
            weapon = 3;
        }
        if (Input.GetKeyDown(KeyCode.Alpha5))
        {
            weapon = 4;
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            weapon++;
            if (weapon >= 4)
            {
                weapon = 4;
            }
        }
        if (Input.GetKeyDown(KeyCode.Q))
        {
            weapon--;
            if (weapon <= 0)
            {
                weapon = 0;
            }
        }

        if (Physics.Raycast(ray, out hit, range))
        {

            #region
           /*
            if (weapon == 4)
            {

                if (Input.GetKeyDown(KeyCode.Space))
                {
                   // print("vehicle selected");
                    onVeh = !onVeh;
                    Debug.Log(onVeh);
                    if (hit.collider.tag == "Vehicle")
                    {

                        //Debug.Log("Hit Vechicle");
                        //Debug.Log(onVeh);
                        if (onVeh)
                        {
                            playCam.InVehicle();
                       //     playMovement.InVehicle();

                            mPlayer.parent = hit.collider.GetComponent<Transform>();
                            mPlayer.localPosition = new Vector3(-2.486229f, 0.32169f, 1.553621f);
                            mPlayer.transform.localRotation = Quaternion.Euler(0.2488809f, 5.57256f, 277.1208f);

                            vehicle = transform.parent.transform.parent.transform.parent.GetComponent<Vehicle>();
                            vehicle.onVehicle = !vehicle.onVehicle;

                        }

                    }
                }
            }
            else
            {
                range = 1000.0f;
            }
            * */
        #endregion

                range = 1000.0f;

                if (Input.GetMouseButtonDown(0))
                {

                    line.enabled = true;
                    line.SetPosition(0, transform.position);
                    line.SetPosition(1, hit.point + hit.normal);

                    effects.RPC("Shot", RPCMode.All, pos, dir, true);
                    laserAudio.Play();

                    AmmoChecks();

                    if (hit.collider.tag == "PlayerDeathParticle")
                    {
                        hit.rigidbody.AddForceAtPosition(2000 * dir, hit.point);
                    }

                    switch (weapon)
                    {

                        case 0:
                            {
                                // Regular Laser
                                // put if ammo > 0 or whatever
                                if (laserAmmo > 0)
                                {

                                    print("laser");

                                    if (hit.collider.tag == "Player")
                                    {
                                        nView = hit.collider.GetComponent<NetworkView>();
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                    }
                                if (hit.collider.tag == "Orb")
                                {
                                    nView = hit.collider.GetComponent<NetworkView>();
                                    nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                    if (nView.isMine)
                                    {
                                        Companion companion;
                                        companion = nView.GetComponent<Companion>();
                                        companion.ClientTakeDamageFromWeapon();
                                    }
                                    else
                                    {
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                    }
                                }

                                    //// BOSSS

                                if (hit.collider.tag == "Boss")
                                {
                                    nView = hit.collider.GetComponent<NetworkView>();
                                   // nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                    if (nView.isMine)
                                    {
                                        Sentry boss;
                                        boss = nView.GetComponent<Sentry>();
                                        boss.ClientTakeDamageFromWeapon(5);
                                    }
                                    else
                                    {
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                    }
                                }

                                if (hit.collider.tag == "SentryHealth1")
                                {
                                    nView = hit.collider.GetComponent<NetworkView>();
                                    if (nView.isMine)
                                    {
                                        SentryHealth sentryHealth;
                                        sentryHealth = nView.GetComponent<SentryHealth>();
                                        sentryHealth.ClientTakeDamageFromWeapon(5);

                                    }
                                    else
                                    {
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                    }

                                }
                                if (hit.collider.tag == "SentryHealth2")
                                {
                                    nView = hit.collider.GetComponent<NetworkView>();
                                    if (nView.isMine)
                                    {
                                        SentryHealth sentryHealth;
                                        sentryHealth = nView.GetComponent<SentryHealth>();
                                        sentryHealth.ClientTakeDamageFromWeapon(5);
                                    }

                                }

                                if (laserAmmo == 0)
                                    {
                                        StartCoroutine(LaserAmmoSpawn());
                                    }

                                    Vector3 explosionPos = new Vector3(hit.point.x, hit.point.y, hit.point.z);
                                    effects.RPC("LaserHit", RPCMode.All, explosionPos);

                                    laserAmmo--;
                                }

                                break;
                            }
                        case 1:
                            {
                                // Incendairy Laser
                                if (incendaryAmmo > 0)
                                {
                                    print("Incendairy");
                                    if (hit.collider.tag == "Player")
                                    {
                                        nView = hit.collider.GetComponent<NetworkView>();
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 10);
                                    }
                                    if (hit.collider.tag == "Orb")
                                    {
                                        nView = hit.collider.GetComponent<NetworkView>();
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                        if (nView.isMine)
                                        {
                                            Companion companion;
                                            companion = nView.GetComponent<Companion>();
                                            companion.ClientTakeDamageFromWeapon();
                                        }
                                        else
                                        {
                                            nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 5);
                                        }
                                    }

                                    if (hit.collider.tag == "Boss")
                                     {
                                    nView = hit.collider.GetComponent<NetworkView>();
                                    nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 10);
                                    if (nView.isMine)
                                    {
                                        Sentry boss;
                                        boss = nView.GetComponent<Sentry>();
                                        boss.ClientTakeDamageFromWeapon(10);
                                    }
                                    else
                                    {
                                        nView.RPC("NetworkTakeDamageFromWeapon", nView.owner, 10);
                                    }
                                }
                                    incendaryAmmo--;
                                    Vector3 explosionPos = new Vector3(hit.point.x, hit.point.y, hit.point.z);
                                    effects.RPC("Explosion", RPCMode.All, explosionPos);
                                }
                                else
                                {
                                    weapon = 0;
                                }

                                break;
                            }
                        case 2:
                            {
                                // Flash Laser
                                if (flashAmmo > 0)
                                {

                                    print("flash");
                                    flashAmmo--;
                                    Vector3 explosionPos = new Vector3(hit.point.x, hit.point.y, hit.point.z);
                                    effects.RPC("FlashExplosion", RPCMode.All, explosionPos);

                                }
                                else
                                {
                                    weapon = 0;
                                }
                                break;
                            }
                        case 3:
                            {
                                // Stasis Laser
                                if (stasisAmmo > 0)
                                {
                                    if (hit.collider.tag == "Player")
                                    {
                                        print("stasis");

                                        nView = hit.collider.GetComponent<NetworkView>();
                                        nView.RPC("Stasis", nView.owner);
                                    }
                                    stasisAmmo--;
                                }
                                else
                                {
                                    weapon = 0;
                                }
                                break;
                            }
                        case 4:
                            {
                                // Levi

                                if (leviAmmo > 0)
                                {
                                    if (hit.collider.tag == "Player")
                                    {
                                        nView = hit.collider.GetComponent<NetworkView>();
                                        nView.RPC("Levitation", nView.owner, 5);

                                    }
                                    leviAmmo--;
                                }
                                else
                                {
                                    weapon = 0;
                                }
                                break;
                            }
                        case 5:
                            {
                                // new ammo goes here, sniffer
                                if (seekerAmmo > 0)
                                {

                                    if (hit.collider.tag == "Player")
                                    {
                                        nView = hit.collider.GetComponent<NetworkView>();
                                        nView.RPC("Seek", nView.owner);
                                    }
                                    seekerAmmo--;
                                }
                                else
                                {
                                    weapon = 0;
                                }

                                break;
                            }
                        case 6:
                            {
                                if (NukeAmmo > 0)
                                {
                                    Vector3 explosionPos = new Vector3(hit.point.x, hit.point.y, hit.point.z);
                                    effects.RPC("NukeHit", RPCMode.All, explosionPos);
                                }
                                else
                                {
                                    weapon = 0;
                                }

                                break;
                            }

                    }
                }
                else
                {
                    effects.RPC("Shot", RPCMode.All, pos, dir, false);
                    line.enabled = false;
                }

        }
    }