Exemplo n.º 1
0
    public int UpdateAbilities(LivingPlaceable character, Vector3Int position)

    {
        if (character == null)
        {
            return(0);
        }
        GameObject zoneToclear = gameCanvas.transform.Find("Skill Zone").gameObject;

        ClearZone(zoneToclear);
        int numberInstantiated = 0;

        foreach (Skill skill in character.Skills)
        {
            GameObject ability = Instantiate(prefabAbilityButton, SkillZone);
            Button     button  = ability.GetComponentInChildren <Button>();
            button.GetComponent <SkillInfo>().Skill        = skill;
            ability.transform.localPosition                = new Vector3(-431 + AbilityGap * numberInstantiated, 0);
            button.GetComponentInChildren <Image>().sprite = skill.AbilitySprite;
            if (skill.TourCooldownLeft > 0)
            {
                //button.GetComponent<Text>().text = skill.TourCooldownLeft.ToString();
                button.GetComponentInChildren <Image>().color = Color.gray;
            }
            button.onClick.AddListener(skill.Activate);
            button.onClick.AddListener(SoundHandler.Instance.PlayUISound);
            numberInstantiated++;
        }
        if (character.EquipedWeapon != null && character.EquipedWeapon.Skills != null)
        {
            foreach (Skill skill in character.EquipedWeapon.Skills)
            {
                Button button = Instantiate(prefabAbilityButton, SkillZone).GetComponentInChildren <Button>();
                button.GetComponent <SkillInfo>().Skill = skill;
                button.GetComponent <RectTransform>().transform.localPosition = new Vector3(-431 + AbilityGap * numberInstantiated, 0);
                button.GetComponentInChildren <Image>().sprite = skill.AbilitySprite;
                button.onClick.AddListener(skill.Activate);
                button.onClick.AddListener(SoundHandler.Instance.PlayUISound);
                numberInstantiated++;
                Debug.Log("new skill from weapon");
            }
        }
        foreach (ObjectOnBloc obj in GameManager.instance.GetObjectsOnBlockUnder(position))
        {
            foreach (Skill skill in obj.GivenSkills)
            {
                GameObject ability = Instantiate(prefabAbilityButton, SkillZone);
                Button     button  = ability.GetComponentInChildren <Button>();
                button.GetComponent <SkillInfo>().Skill = skill;
                ability.GetComponent <RectTransform>().transform.localPosition = new Vector3(-431 + AbilityGap * numberInstantiated, 0);
                button.GetComponentInChildren <Image>().sprite = skill.AbilitySprite;
                button.onClick.AddListener(skill.Activate);
                button.onClick.AddListener(SoundHandler.Instance.PlayUISound);
                numberInstantiated++;
                Debug.Log("new skill from objectonbloc");
            }
        }
        return(numberInstantiated);
    }
Exemplo n.º 2
0
    //TODO : MANAGE SKILL CREATION AND USAGE (WAITING FOR SKILL'S PROPER IMPLEMENTATION)
    //Make a copy from model skill in skills, and fill with additional info (caster, targets)
    public void UseSkill(int skillID, LivingPlaceable caster, List <NetIdeable> targets)
    {
        Skill skill = playingPlaceable.Skills[skillID];

        if (caster.CurrentPA > skill.Cost && skill.Use(caster, targets))
        {
            caster.CurrentPA = caster.CurrentPA - skill.Cost > 0 ? caster.CurrentPA - skill.Cost : 0; //On clamp à 0, on est pas trop sur de ce qui a pu se passer dans le use
        }
    }
Exemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        LivingPlaceable living = (LivingPlaceable)base.target;

        if (GUILayout.Button("Convert"))
        {
            living.Save(living.ClassName + ".json");
        }
    }
Exemplo n.º 4
0
 public IEnumerator CheckInterruptionsWithRef(float time, LivingPlaceable refPlaceable)
 {
     for (float i = 0; i < time; i = i + 0.1f)
     {
         if (refPlaceable == GameManager.instance.PlayingPlaceable) // TODO case if pa > 1, check selection of skill and break wait
         {
             yield return(new WaitForSeconds(0.1f));
         }
         else
         {
             break;
         }
     }
 }
Exemplo n.º 5
0
    public void Use()
    {
        if (this.Cible is LivingPlaceable)
        {
            LivingPlaceable Cible = (LivingPlaceable)(this.Cible);
            Cible.PvActuels -= Damage1;
            if (Cible.PvActuels <= 0)
            {
                Debug.Log("ouille ouille ouille");

                Cible.Detruire();
            }
        }
    }
Exemplo n.º 6
0
    private void InitialiseCharacter(GameObject charac, GameObject player, Vector3Int spawnCoordinates, string className, int prefabNumber)
    {
        LivingPlaceable charac1 = charac.GetComponent <LivingPlaceable>();

        charac1.Player = player.GetComponent <Player>();
        charac1.Init(prefabNumber);
        Vector3Int posPers = spawnCoordinates;

        Grid.instance.GridMatrix[posPers.x, posPers.y, posPers.z] = charac1;
        charac1.Weapons.Add(Instantiate(prefabWeapons[0], charac.transform)); // to change in function of the start weapon
        charac1.EquipedWeapon = charac1.Weapons[0].GetComponent <Weapon>();
        charac1.netId         = Placeable.currentMaxId;
        //Debug.Log(charac1.netId);
        idPlaceable[charac1.netId] = charac1;
        Placeable.currentMaxId++;
    }
Exemplo n.º 7
0
 public void Activate(LivingPlaceable character)
 {
     gameObject.SetActive(true);
     className.text = "Name : " + character.ClassName;
     player.text    = "Player : xXDarkSasukeXx";
     team.text      = "Team : " + character.Player.name;
     hp.text        = "HP : " + character.CurrentHP;
     mov.text       = "MOV : " + character.CurrentPM;
     speed.text     = "SPEED : " + character.Speed;
     dext.text      = "DEXT : " + character.Dexterity;
     def.text       = "DEF : " + character.Def;
     mDef.text      = "M.DEF : " + character.Mdef;
     str.text       = "STR : " + character.Force;
     mStr.text      = "M.STR : " + character.Mstr;
     image.sprite   = character.characterSprite;
 }
Exemplo n.º 8
0
    ///TODO makes the copy and return if succeeded launching the skill
    public bool Use(LivingPlaceable caster, List <NetIdeable> targets)
    {
        if (this.tourCooldownLeft > 0)
        {
            return(false);
        }
        if (condition != null && !condition.Invoke())
        {
            return(false);
        }

        List <Animator>  animTargets      = new List <Animator>();
        List <Placeable> placeableTargets = new List <Placeable>();
        List <Vector3>   positionTargets  = new List <Vector3>();

        foreach (Placeable target in targets)
        {
            placeableTargets.Add(target);
            positionTargets.Add(target.GetPosition());
            if (target.GetComponent <Animator>() != null)
            {
                animTargets.Add(target.GetComponent <Animator>());
            }
        }
        SendAnimationInfo(animTargets, placeableTargets, positionTargets);
        PlayAnimation();
        this.tourCooldownLeft = this.cooldown;//On pourrait avoir de la cdr dans les effets afterall
        foreach (Placeable target in targets)
        {
            foreach (Effect effect in effects)
            {
                //makes the deep copy, send it to effect manager and zoo
                Effect effectToConsider = effect.Clone();
                effectToConsider.Launcher = caster;
                //Double dispatch
                target.DispatchEffect(effectToConsider);
            }
        }
        GameManager.instance.activeSkill = null;
        if (GameManager.instance.playingPlaceable.Player.isLocalPlayer)
        {
            GameManager.instance.playingPlaceable.Player.cameraScript.BackToMovement();
        }
        return(true);
    }
Exemplo n.º 9
0
    // checking interruptions if several actions in a row - give playing placeable as ref at the start
    // use if several coroutine in one action (ex : damage -> hurt -> die)

    public IEnumerator CheckContinuousInterruptions(float time, LivingPlaceable refPlaceable, bool interrupted)
    {
        if (!interrupted)
        {
            for (float i = 0; i < time; i = i + 0.1f)
            {
                if (refPlaceable == GameManager.instance.PlayingPlaceable) // TODO case if pa > 1, check selection of skill and break wait
                {
                    yield return(new WaitForSeconds(0.1f));
                }
                else
                {
                    interrupted = true;
                    break;
                }
            }
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// Sets the values of this object from living
    /// </summary>
    /// <param name="living"></param>
    public void FillThis(LivingPlaceable living)
    {
        this.serializeNumber = living.serializeNumber;
        this.netId           = living.netId;
        List <FieldInfo> livingFields = new List <FieldInfo>();

        foreach (FieldInfo fieldInfo in this.GetType().GetFields())
        {
            foreach (FieldInfo fieldLiving in living.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                if (fieldInfo.GetType() == fieldLiving.GetType() && fieldInfo.Name == fieldLiving.Name)
                {
                    fieldInfo.SetValue(this, fieldLiving.GetValue(living));
                    break;
                }
            }
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Fill living from values of this. Equalize any fields that have the same type and the same name
    /// </summary>
    /// <param name="living"></param>
    public void FillLiving(LivingPlaceable living)
    {
        living.serializeNumber = this.serializeNumber;
        living.netId           = this.netId;
        //Debug.LogError(living.PlayerPosesser);
        List <FieldInfo> livingFields = new List <FieldInfo>( );

        foreach (FieldInfo fieldInfo in this.GetType().GetFields())
        {
            foreach (FieldInfo fieldLiving in living.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance))
            {
                if (fieldInfo.GetType() == fieldLiving.GetType() && fieldInfo.Name == fieldLiving.Name)
                {
                    fieldLiving.SetValue(living, fieldInfo.GetValue(this));
                    break;
                }
            }
        }
        //  Debug.LogError("at the end" +this.playerPosesser);
    }
Exemplo n.º 12
0
    public void UpdateTimeline()
    {
        TurnOrder.Clear();
        //add every character once and sort them
        foreach (GameObject character in player1.GetComponent <Player>().Characters)
        {
            LivingPlaceable   placeable    = character.GetComponent <LivingPlaceable>();
            StackAndPlaceable newCharacter = new StackAndPlaceable(placeable, placeable.SpeedStack, false);
            TurnOrder.Add(newCharacter);
        }
        foreach (GameObject character in player2.GetComponent <Player>().Characters)
        {
            LivingPlaceable   placeable    = character.GetComponent <LivingPlaceable>();
            StackAndPlaceable newCharacter = new StackAndPlaceable(placeable, placeable.SpeedStack, false);
            TurnOrder.Add(newCharacter);
        }
        TurnOrder.Sort((x, y) => x.SpeedStack == y.SpeedStack ? 1 : (int)((x.SpeedStack - y.SpeedStack) / (Mathf.Abs(x.SpeedStack - y.SpeedStack))));

        //Check for every Character if it has to play more than once in the "Grand Turn"

        int numberOfTurns = 1;

        for (int i = 0; i < turnOrder.Count - 1; i++)
        {
            StackAndPlaceable check = turnOrder[i];
            if (!check.SeenBefore)
            {
                for (int j = i + 1; j < turnOrder.Count - 1; j++)
                {
                    float compare = check.SpeedStack + ((numberOfTurns * (j - i)) / check.Character.Speed);
                    if (turnOrder[j].SpeedStack > compare)
                    {
                        turnOrder.Insert(j, new StackAndPlaceable(check.Character, check.SpeedStack + numberOfTurns * (j - i) / check.Character.Speed, true));
                        j++;
                    }
                }
            }
            check.SeenBefore = true;
        }
    }
Exemplo n.º 13
0
    // <summary>
    /// Unused function to apply function to all visible characters
    /// </summary>
    /// <param name="shooter"></param>
    public void Shootable(LivingPlaceable shooter)
    {
        Vector3 shootPos = shooter.GetPosition() + shooter.ShootPosition;

        foreach (GameObject iterCharac1 in player1.GetComponent <Player>().Characters)
        {
            LivingPlaceable charac1 = iterCharac1.GetComponent <LivingPlaceable>();

            if (shooter.CanHit(charac1).Count > 0)
            {
                //typically, changing color
            }
        }

        foreach (GameObject iterCharac2 in player2.GetComponent <Player>().Characters)
        {
            LivingPlaceable charac2 = iterCharac2.GetComponent <LivingPlaceable>();

            if (shooter.CanHit(charac2).Count > 0)
            {
                //typically, changing color
            }
        }
    }
Exemplo n.º 14
0
 public virtual void Initialize(LivingPlaceable livingPlaceable)
 {
 }
Exemplo n.º 15
0
 public abstract void TargetAndInvokeEffectManager(LivingPlaceable placeable);
Exemplo n.º 16
0
 /// <summary>
 /// create a damage object
 /// </summary>
 /// <param name="target">target of the action</param>
 /// <param name="launcher">launcher of the action</param>
 /// <param name="damageValue">quanitity of damage given</param>
 public MoveEffect(LivingPlaceable target, Placeable launcher, Vector3Int direction, bool useBezier) : base(target, launcher)
 {
     this.Direction = direction;
     this.UseBezier = useBezier;
 }
Exemplo n.º 17
0
 public override void Initialize(LivingPlaceable livingPlaceable)
 {
     base.Initialize(livingPlaceable);
     this.Target   = livingPlaceable;
     this.Launcher = livingPlaceable;
 }
Exemplo n.º 18
0
 protected EffectOnLiving(LivingPlaceable target, Placeable launcher) : base()
 {
     Target   = target;
     Launcher = launcher;
 }
Exemplo n.º 19
0
 public Damage(LivingPlaceable target, Placeable launcher, float damageValue, int numberOfTurns) : base(target, launcher, numberOfTurns)
 {
     this.DamageValue = damageValue;
 }
Exemplo n.º 20
0
 /// <summary>
 /// create a damage object
 /// </summary>
 /// <param name="target">target of the action</param>
 /// <param name="launcher">launcher of the action</param>
 /// <param name="damageValue">quanitity of damage given</param>
 public Damage(LivingPlaceable target, Placeable launcher, float damageValue) : base(target, launcher)
 {
     this.DamageValue = damageValue;
 }
Exemplo n.º 21
0
 public override void Initialize(LivingPlaceable livingPlaceable)
 {
     base.Initialize(livingPlaceable);
     expression = MethodsForEffects[numberMethod];
 }
Exemplo n.º 22
0
 public override void TargetAndInvokeEffectManager(LivingPlaceable placeable)
 {
     Target = placeable;
     EffectManager.instance.DirectAttack(this);
 }
Exemplo n.º 23
0
 protected EffectOnLiving(LivingPlaceable target, Placeable launcher, int numberOfTurns) : base(numberOfTurns)
 {
     Target   = target;
     Launcher = launcher;
 }
Exemplo n.º 24
0
 public override void Initialize(LivingPlaceable livingPlaceable)
 {
     base.Initialize(livingPlaceable);
     prefab = Grid.instance.prefabsList[prefabListNumber];
 }
Exemplo n.º 25
0
 //Do nothing if living
 public override void TargetAndInvokeEffectManager(LivingPlaceable placeable)
 {
 }
Exemplo n.º 26
0
 public override void Initialize(LivingPlaceable livingPlaceable)
 {
     base.Initialize(livingPlaceable);
 }
Exemplo n.º 27
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;
    }
Exemplo n.º 28
0
    /// <summary>
    /// Fonction permettant de trouver et afficher un chemin d'un point A à un point B
    /// Seuls les cases sur lesquelles on est sûrs de pouvoir aller sont ajoutées
    /// <param name="deplacement">Valeur de déplacement d'un personnage</param>
    /// <param name="saut">Valeur de saut d'un personnage</param>
    /// <param name="positionBloc">Position du bloc de départ, c'est à dire celui SOUS le personnage</param>
    /// <returns>Retourne une grille qui permet d'avoir les positions de chacun des blocs du chemin, c'est à dire les blocs appartenant au SOL. Le personnage se déplacera une case au dessus</returns>
    /// </summary>
    public DistanceAndParent[,,] CanGo(LivingPlaceable livingPlaceable, int saut, Vector3Int positionBloc)
    {
        int deplacement = livingPlaceable.PmActuels;



        for (int x = 0; x < sizeX; x++)
        {
            for (int y = 0; y < sizeY; y++)
            {
                for (int z = 0; z < sizeZ; z++)
                {
                    gridBool[x, y, z] = new DistanceAndParent(x, y, z);
                }
            }
        }

        Queue <Vector3Int> queue = new Queue <Vector3Int>();

        queue.Enqueue(positionBloc);
        DistanceAndParent parent = null;

        gridBool[positionBloc.x, positionBloc.y, positionBloc.z].SetDistance(0);
        while (parent == null || ((parent.GetDistance() <= deplacement) && queue.Count != 0))
        {
            //On mets ceux à coté, ceux au dessus accessibles ou ceux en dessous accessibles
            //coté

            Vector3Int posBlocActuel = queue.Dequeue();


            parent = gridBool[posBlocActuel.x, posBlocActuel.y, posBlocActuel.z];
            if (parent.GetDistance() <= deplacement)
            {
                Placeable testa = Grid[posBlocActuel.x, posBlocActuel.y, posBlocActuel.z];
                if (testa.gameObject.GetComponent <Renderer>() != null)
                {
                    //On envoie plutot l'id parce que rien n'assure que les blocs soient a la bonne position coté client
                    gameManager.PlayingPlaceable.Joueur.RpcMakeCubeBlue(testa.netId);
                }
                //là mettre l'affichage du bloc en bleu
                for (int yactuel = -saut + 1; yactuel < saut; yactuel++)
                {
                    if (posBlocActuel.y + yactuel >= 0 && posBlocActuel.y + yactuel < sizeY && posBlocActuel.x < sizeX - 1 && //au dessus de 0, en dessous du max, dans le terrain en x
                        gridBool[posBlocActuel.x + 1, posBlocActuel.y + yactuel, posBlocActuel.z].GetDistance() == -1 &&      //si on l'a pas dejà vu
                        Grid[posBlocActuel.x + 1, posBlocActuel.y + yactuel, posBlocActuel.z] != null &&                      // et si le bloc existe
                        (Grid[posBlocActuel.x + 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z] == null || //si le bloc au dessus est vide
                         Grid[posBlocActuel.x + 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z].TraversableChar == TraversableType.ALLTHROUGH || //ou traversable en général
                         Grid[posBlocActuel.x + 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z].TraversableChar == TraversableType.ALLIESTHROUGH &&   //ou seulement par un allié
                         Grid[posBlocActuel.x + 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z].Joueur == livingPlaceable.Joueur) && //si on est l'allié
                        Grid[posBlocActuel.x + 1, posBlocActuel.y + yactuel, posBlocActuel.z].Walkable
                        )
                    {//si le sommet n'est pas marqué et qu'il existe, et qu'il n'y a rien au dessus ou que celui du dessus est traversable, que le bloc est walkable
                        queue.Enqueue(new Vector3Int(posBlocActuel.x + 1, posBlocActuel.y + yactuel, posBlocActuel.z));
                        gridBool[posBlocActuel.x + 1, posBlocActuel.y + yactuel, posBlocActuel.z].SetDistance(
                            parent.GetDistance() + 1);
                        gridBool[posBlocActuel.x + 1, posBlocActuel.y + yactuel, posBlocActuel.z].SetParent(parent);
                    }

                    if (posBlocActuel.y + yactuel >= 0 && posBlocActuel.y + yactuel < sizeY && posBlocActuel.x > 0 &&
                        gridBool[posBlocActuel.x - 1, posBlocActuel.y + yactuel, posBlocActuel.z].GetDistance() == -1 &&
                        Grid[posBlocActuel.x - 1, posBlocActuel.y + yactuel, posBlocActuel.z] != null &&
                        (Grid[posBlocActuel.x - 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z] == null ||
                         Grid[posBlocActuel.x - 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z].TraversableChar == TraversableType.ALLTHROUGH ||
                         Grid[posBlocActuel.x - 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z].TraversableChar == TraversableType.ALLIESTHROUGH &&
                         Grid[posBlocActuel.x - 1, posBlocActuel.y + yactuel + 1, posBlocActuel.z].Joueur == livingPlaceable.Joueur) &&
                        Grid[posBlocActuel.x - 1, posBlocActuel.y + yactuel, posBlocActuel.z].Walkable)
                    {//si le sommet n'est pas marqué et qu'il existe, et qu'il n'y a rien au dessus
                        queue.Enqueue(new Vector3Int(posBlocActuel.x - 1, posBlocActuel.y + yactuel, posBlocActuel.z));
                        gridBool[posBlocActuel.x - 1, posBlocActuel.y + yactuel, posBlocActuel.z].SetDistance(
                            parent.GetDistance() + 1);
                        gridBool[posBlocActuel.x - 1, posBlocActuel.y + yactuel, posBlocActuel.z].SetParent(parent);
                    }
                    if (posBlocActuel.y + yactuel >= 0 && posBlocActuel.y + yactuel < sizeY && posBlocActuel.z < sizeZ - 1 &&
                        gridBool[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z + 1].GetDistance() == -1 &&
                        Grid[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z + 1] != null &&
                        (Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z + 1] == null ||
                         Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z + 1].TraversableChar == TraversableType.ALLTHROUGH ||
                         Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z + 1].TraversableChar == TraversableType.ALLIESTHROUGH &&
                         Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z + 1].Joueur == livingPlaceable.Joueur) &&
                        Grid[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z + 1].Walkable)

                    {//si le sommet n'est pas marqué et qu'il existe et qu'il n'y a rien au dessus
                        queue.Enqueue(new Vector3Int(posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z + 1));
                        gridBool[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z + 1].SetDistance(
                            parent.GetDistance() + 1);
                        gridBool[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z + 1].SetParent(parent);
                    }
                    if (posBlocActuel.y + yactuel >= 0 && posBlocActuel.y + yactuel < sizeY && posBlocActuel.z > 0 &&
                        gridBool[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z - 1].GetDistance() == -1 &&
                        Grid[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z - 1] != null &&
                        (Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z - 1] == null ||
                         Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z - 1].TraversableChar == TraversableType.ALLTHROUGH ||
                         Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z - 1].TraversableChar == TraversableType.ALLIESTHROUGH &&
                         Grid[posBlocActuel.x, posBlocActuel.y + yactuel + 1, posBlocActuel.z - 1].Joueur == livingPlaceable.Joueur) &&
                        Grid[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z - 1].Walkable)
                    {//si le sommet n'est pas marqué et qu'il existe, et qu'il n'y a rien au dessus
                        queue.Enqueue(new Vector3Int(posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z - 1));
                        gridBool[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z - 1].SetDistance(
                            parent.GetDistance() + 1);
                        gridBool[posBlocActuel.x, posBlocActuel.y + yactuel, posBlocActuel.z - 1].SetParent(parent);
                    }
                }
            }
        }

        return(gridBool);
    }
Exemplo n.º 29
0
 public StackAndPlaceable(LivingPlaceable character, float speedStack, bool seenBefore)
 {
     this.Character  = character;
     this.SpeedStack = speedStack;
     this.SeenBefore = seenBefore;
 }