コード例 #1
0
        public static Render.Face Convert(Face face, Model model)
        {
            List <Vector3> positions = face.Positions == null
                ? new List <Vector3>()
                : Converter.ConvertVector3List(face.Positions);

            List <Vector2> textureMap = face.TextureMap == null
                ? new List <Vector2>()
                : Converter.ConvertVector2List(face.TextureMap);

            Vector3?normal = face.Normal == null
                ? null
                : (Vector3?)Converter.ConvertVector3(face.Normal);

            Side contact = face.Contact == null
                ? Side.None
                : SideMethods.FromString(face.Contact);

            if (face.Data != null)
            {
                AddData(face.Data, model.Positions, model.TextureMap, positions, textureMap);

                if (face.Data.Normal != null && model.Normals != null)
                {
                    normal = Converter.Vector3FromData(model.Normals, (int)face.Data.Normal);
                }
            }

            return(new Render.Face(positions.ToArray(), textureMap.ToArray(), face.Layer ?? 0, contact, normal));
        }
コード例 #2
0
        public static Render.Model Convert(Model model)
        {
            Render.Face[] faces = model.Faces == null
                ? new Render.Face[0]
                : model.Faces.Select(f => FaceConverter.Convert(f, model)).ToArray();

            Side fullSides = model.FullSides == null
                ? Side.None
                : SideMethods.FromString(model.FullSides);

            return(new Render.Model(faces, fullSides));
        }
コード例 #3
0
 internal void UpdateAdjacentModels()
 {
     foreach (GameObject go in GetComponent <ScrollableList>().ElementsToPut)
     {
         PanelTile   pt = go.GetComponent <PanelTile>();
         AvatarModel am = go.GetComponent <PanelTile>().PanelAvatar.GetComponent <PanelAvatar>().Model;
         if (am != null)
         {
             foreach (Side s in SideMethods.AllSides())
             {
                 if (pt.Neighbours.ContainsKey(s))
                 {
                     am.AdjacentModels[s] = pt.Neighbours[s].PanelAvatar.GetComponent <PanelAvatar>().Model;
                 }
             }
         }
     }
 }
コード例 #4
0
    internal bool CanHeHaveThisSpell(PanelTile target, PanelTile onWhat, Card card)
    {
        AvatarModel casterModel = PanelAvatar.GetComponent <PanelAvatar>().Model;
        AvatarModel targetModel = target.PanelAvatar.GetComponent <PanelAvatar>().Model;
        AvatarModel onWhatModel = onWhat.PanelAvatar.GetComponent <PanelAvatar>().Model;

        bool canIHave = false;

        switch (card.IsCastOn)
        {
        case IsCastOn.Target:
            canIHave = onWhat == target;
            break;

        case IsCastOn.FriendlyMinions:
            canIHave = onWhatModel != null && casterModel.GetMyHero().IsItYourMinion(onWhatModel);
            break;

        case IsCastOn.AdjacentCharacters:
            if (onWhatModel != null)
            {
                foreach (Side s in SideMethods.AllSides())
                {
                    //we have to compare panelTiles instead of AvatarModels, because we could compare null to null
                    if (target.Neighbours.ContainsKey(s) && target.Neighbours[s] == onWhat)
                    {
                        canIHave = true;
                    }
                }
            }
            break;

        case IsCastOn.AllCharactersInLineFromThis:
            //define the line
            int dRow = target.Row - Row;
            int dCol = target.Column - Column;

            Side      s2           = SideMethods.GetSide(dRow, dCol);
            PanelTile tmp          = target;
            bool      thisIsOnLine = false;

            while (tmp != null)
            {
                thisIsOnLine = tmp == onWhat;
                if (thisIsOnLine)
                {
                    break;
                }
                if (tmp.Neighbours.ContainsKey(s2))
                {
                    tmp = tmp.Neighbours[s2];
                }
                else
                {
                    break;
                }
            }
            canIHave = thisIsOnLine;
            break;

        case IsCastOn.AdjacentMinions:

            if (onWhatModel != null && onWhatModel.Card.CardPersistency == CardPersistency.Minion)
            {
                foreach (Side s in SideMethods.AllSides())
                {
                    //we have to compare panelTiles instead of AvatarModels, because we could compare null to null
                    if (target.Neighbours.ContainsKey(s) && target.Neighbours[s] == onWhat)
                    {
                        canIHave = true;
                    }
                }
            }
            break;

        case IsCastOn.FriendlyAdjacentMinions:
            if (onWhatModel != null && casterModel.GetMyHero().IsItYourMinion(onWhatModel))
            {
                foreach (Side s in SideMethods.AllSides())
                {
                    //we have to compare panelTiles instead of AvatarModels, because we could compare null to null
                    if (Neighbours.ContainsKey(s) && Neighbours[s] == onWhat)
                    {
                        canIHave = true;
                    }
                }
            }
            break;

        case IsCastOn.FriendlyAdjacentCharacters:
            if (onWhatModel != null && (casterModel.GetMyHero().IsItYourMinion(onWhatModel) || targetModel.GetMyHero() == casterModel))
            {
                foreach (Side s in SideMethods.AllSides())
                {
                    //we have to compare panelTiles instead of AvatarModels, because we could compare null to null
                    if (Neighbours.ContainsKey(s) && Neighbours[s] == onWhat)
                    {
                        canIHave = true;
                    }
                }
            }
            break;

        case IsCastOn.OtherFriendlyMinions:
            canIHave = onWhatModel != null && casterModel.GetMyHero().IsItYourMinion(onWhatModel) && targetModel != onWhatModel;
            break;

        case IsCastOn.EnemyCharacters:
            canIHave = onWhatModel != null && onWhatModel.GetMyHero() != casterModel.GetMyHero();
            break;

        case IsCastOn.OtherItsCharacters:
            canIHave = onWhatModel != null && onWhatModel != targetModel && targetModel.GetMyHero() == onWhatModel.GetMyHero();
            break;

        case IsCastOn.FriendlyHero:
            canIHave = casterModel.GetMyHero() == onWhatModel;
            break;

        case IsCastOn.EnemyMinions:
            canIHave = onWhatModel != null && onWhatModel.GetMyHero() != casterModel.GetMyHero() && onWhatModel.GetMyHero().IsItYourMinion(onWhatModel);
            break;

        case IsCastOn.FriendlyCharacters:
            canIHave = onWhatModel != null && casterModel.IsFriendlyCharacter(onWhatModel);
            break;

        case IsCastOn.EnemyHero:
            canIHave = onWhatModel != null && onWhatModel.Card.CardPersistency == CardPersistency.Hero && !onWhatModel.IsFriendlyCharacter(casterModel);
            break;

        default:
            throw new NotImplementedException("Implement case: " + card.IsCastOn);
        }
        return(canIHave);
    }
コード例 #5
0
    public bool SetInteractionToMoveAround()
    {
        bool canMove = false;

        //check for adjacent taunt
        //check for adjacent sticky enemy characters
        bool        foundTaunt       = false;
        bool        foundStickyEnemy = false;
        List <Side> whereTaunts      = new List <Side>();

        foreach (Side s in SideMethods.AllSides())
        {
            if (Neighbours.ContainsKey(s))
            {
                AvatarModel m = Neighbours[s].PanelAvatar.GetComponent <PanelAvatar>().Model;
                if (m != null && !m.IsFriendlyCharacter(PanelAvatar.GetComponent <PanelAvatar>().Model))
                {
                    foreach (CastedCard cc in m.Effects)
                    {
                        if (cc.Params.ContainsKey(CastedCardParamType.Taunt))
                        {
                            foundTaunt = true;
                            whereTaunts.Add(s);
                        }
                        if (cc.Params.ContainsKey(CastedCardParamType.Sticky))
                        {
                            foundStickyEnemy = true;
                        }
                    }
                }
            }
        }

        AvatarModel am = PanelAvatar.GetComponent <PanelAvatar>().Model;

        foreach (Side s in SideMethods.AllSides())
        {
            if (Neighbours.ContainsKey(s))
            {
                PanelTile whereMove = Neighbours[s];

                if (whereMove.PanelAvatar.GetComponent <PanelAvatar>().Model == null)
                {
                    if (!foundStickyEnemy)
                    {
                        whereMove.PanelInteraction.GetComponent <PanelInteraction>().CanMoveHere(this);
                        canMove = true;
                    }
                }
                else if (!PanelAvatar.GetComponent <PanelAvatar>().Model.IsFriendlyCharacter(whereMove.PanelAvatar.GetComponent <PanelAvatar>().Model) &&
                         am.ActualAttack > 0 &&
                         (!foundTaunt || whereTaunts.Contains(s)))
                {
                    whereMove.PanelInteraction.GetComponent <PanelInteraction>().CanAttackHere(this);
                    canMove = true;
                }
            }
        }

        return(canMove);
    }