コード例 #1
0
 public PickObjectOnBlockEffect(ObjectOnBloc target)
 {
     Target = target;
 }
コード例 #2
0
ファイル: Effect.cs プロジェクト: Roxasispoor/Tiaren
 public abstract void TargetAndInvokeEffectManager(ObjectOnBloc placeable);
コード例 #3
0
ファイル: EffectOnLiving.cs プロジェクト: Roxasispoor/Tiaren
 public override void TargetAndInvokeEffectManager(ObjectOnBloc placeable)
 {
 }
コード例 #4
0
    /// <summary>
    /// Connect to server and listen for the data incoming until it receive EOF
    /// player is localClient that reconnects
    /// WARNING: prefabList must be kept up to date and contain all living with index being their serialize id
    /// </summary>
    /// <returns></returns>
    public IEnumerator ListenToData(Player player)
    {
        List <ObjectOnBloc> toInit = new List <ObjectOnBloc>();

        server = new TcpClient(networkManager.networkAddress, networkManager.networkPort);
        Byte[] bytes         = new Byte[1024];
        string serverMessage = "";
        string totalMessage  = "";

        using (NetworkStream stream = server.GetStream())
        {
            while (!serverMessage.EndsWith(endChar))
            {
                try
                {
                    int length;
                    // Read incomming stream into byte arrary.
                    while (stream.DataAvailable && (length = stream.Read(bytes, 0, bytes.Length)) != 0)
                    {
                        byte[] incommingData = new byte[length];
                        Array.Copy(bytes, 0, incommingData, 0, length);
                        // Convert byte array to string message.
                        serverMessage = Encoding.ASCII.GetString(incommingData);
                        totalMessage += serverMessage;
                        Debug.Log("server message received as: " + serverMessage);
                    }
                }
                catch (SocketException socketException)
                {
                    Debug.Log("Socket exception: " + socketException);
                }
                yield return(null);
            }

            Debug.Log("Coroutine, splitting now");
            string[] files = totalMessage.Split(betweenFilesChar.ToCharArray());
            Debug.Log(files);
            GameManager.instance.player2.GetComponent <Player>().Characters.Clear();
            GameManager.instance.player1.GetComponent <Player>().Characters.Clear();
            //Parse type to see what to create
            foreach (string str in files)
            {
                if (str.EndsWith(stringGrid))
                {
                    Debug.Log("File grid detected");
                    string strCopy = str.TrimEnd(stringGrid.ToCharArray());

                    GameManager.instance.ResetGrid();
                    //Deletes old grid, fill it anew

                    Grid.instance.FillGridAndSpawnNetwork(GameManager.instance.gridFolder, strCopy);
                }

                else if (str.EndsWith(stringLiving))
                {
                    Debug.Log("Living detected");
                    string strCopy = str.TrimEnd(stringLiving.ToCharArray());

                    string       line   = "";
                    StreamReader reader = new StreamReader(LivingPlaceable.GenerateStreamFromString(strCopy));
                    if ((line = reader.ReadLine()) == null)
                    {
                        Debug.Log("Empty file while reading living form file!");
                        yield return(null);
                    }
                    Stats newLivingStats = JsonUtility.FromJson <Stats>(line);

                    //Spawns
                    if (newLivingStats.playerPosesser == "player1")
                    {
                        Debug.LogError("Create perso 1" + newLivingStats.serializeNumber);
                        GameObject charac = Instantiate(Grid.instance.prefabsList[newLivingStats.serializeNumber - 1],
                                                        newLivingStats.positionSave, Quaternion.identity);
                        LivingPlaceable charac1 = charac.GetComponent <LivingPlaceable>();

                        GameManager.instance.player1.GetComponent <Player>().Characters.Add(charac);
                        charac1.Player = GameManager.instance.player1.GetComponent <Player>();
                        Vector3Int posPers = new Vector3Int((int)newLivingStats.positionSave.x, (int)newLivingStats.positionSave.y,
                                                            (int)newLivingStats.positionSave.z);
                        Grid.instance.GridMatrix[posPers.x, posPers.y, posPers.z] = charac1;
                        charac1.Weapons.Add(Instantiate(GameManager.instance.prefabWeapons[0], charac.transform)); // to change in function of the start weapon
                        charac1.EquipedWeapon = charac1.Weapons[0].GetComponent <Weapon>();
                        charac1.InitNoClass();
                        charac1.LoadFromString(strCopy);
                        GameManager.instance.idPlaceable[charac1.netId] = charac1;
                        NetIdeable.currentMaxId = charac1.netId >= NetIdeable.currentMaxId ? charac1.netId + 1 : NetIdeable.currentMaxId;
                        foreach (Skill skill in charac1.Skills)
                        {
                            skill.AbilitySprite = Resources.Load <Sprite>("UI_Images/Abilities/" + skill.SkillName);
                        }
                    }
                    else if (newLivingStats.playerPosesser == "player2")
                    {
                        Debug.LogError("Create perso 2" + newLivingStats.serializeNumber);
                        GameObject charac = Instantiate(Grid.instance.prefabsList[newLivingStats.serializeNumber - 1],
                                                        newLivingStats.positionSave, Quaternion.identity);
                        LivingPlaceable charac1 = charac.GetComponent <LivingPlaceable>();

                        GameManager.instance.player2.GetComponent <Player>().Characters.Add(charac);
                        charac1.Player = GameManager.instance.player2.GetComponent <Player>();
                        Vector3Int posPers = new Vector3Int((int)newLivingStats.positionSave.x, (int)newLivingStats.positionSave.y,
                                                            (int)newLivingStats.positionSave.z);
                        Grid.instance.GridMatrix[posPers.x, posPers.y, posPers.z] = charac1;
                        charac1.Weapons.Add(Instantiate(GameManager.instance.prefabWeapons[0], charac.transform)); // to change in function of the start weapon
                        charac1.EquipedWeapon = charac1.Weapons[0].GetComponent <Weapon>();
                        charac1.InitNoClass();
                        charac1.LoadFromString(strCopy);

                        GameManager.instance.idPlaceable[charac1.netId] = charac1;
                        NetIdeable.currentMaxId = charac1.netId >= NetIdeable.currentMaxId ? charac1.netId + 1 : NetIdeable.currentMaxId;

                        foreach (Skill skill in charac1.Skills)
                        {
                            skill.AbilitySprite = Resources.Load <Sprite>("UI_Images/Abilities/" + skill.SkillName);
                        }
                    }
                }
                else if (str.EndsWith(stringObjectOnBloc))
                {
                    string       strCopyObj = str.TrimEnd(stringObjectOnBloc.ToCharArray());
                    string       newline    = "";
                    StreamReader reader     = new StreamReader(LivingPlaceable.GenerateStreamFromString(strCopyObj));
                    while ((newline = reader.ReadLine()) != null)
                    {
                        string[]   objectInfo   = newline.Split(';');
                        Vector3Int positionObj  = StringToVector3Int(objectInfo[2]);
                        GameObject objectonbloc = Instantiate(Grid.instance.prefabsList[Int32.Parse(objectInfo[0]) - 1],
                                                              positionObj, Quaternion.identity, Grid.instance.GetPlaceableFromVector(positionObj).transform);
                        ObjectOnBloc objectOnBloc1 = objectonbloc.GetComponent <ObjectOnBloc>();
                        objectOnBloc1.netId     = Int32.Parse(objectInfo[1]);
                        NetIdeable.currentMaxId = objectOnBloc1.netId >= NetIdeable.currentMaxId ? objectOnBloc1.netId + 1 : NetIdeable.currentMaxId;
                        objectOnBloc1.Load(objectInfo);
                        GameManager.instance.idPlaceable[objectOnBloc1.netId] = objectOnBloc1;
                        toInit.Add(objectOnBloc1);
                    }
                }
            }
            foreach (ObjectOnBloc objToInit in toInit)
            {
                objToInit.Initialize();
            }
            GameManager.instance.ResetAllBatches();
            Debug.Log("I ended the coroutine reconnect me now");
            player.CmdReconnectMe();
            //We suppose we found back our initial place thanks to start

            /* Player[] players = FindObjectsOfType<Player>();
             * foreach(Player player in players)
             * {
             *   if(player.isLocalPlayer)//Contact everyone to tell them
             *   {
             *       player.CmdReconnectMe();
             *   }
             * }*/
        }
        server.Close();
        server = null;
    }
コード例 #5
0
 public EffectOnObjectBloc(ObjectOnBloc target, int numberOfTurns = 1) : base(numberOfTurns)
 {
     Target = target;
 }
コード例 #6
0
 public EffectOnObjectBloc(EffectOnObjectBloc other) : base(other)
 {
     Target = other.target;
 }
コード例 #7
0
 public override void TargetAndInvokeEffectManager(ObjectOnBloc placeable)//TODO, doesn't work
 {
     Target = placeable;
     EffectManager.instance.DirectAttack(this);
 }