コード例 #1
0
    //Function called from CombatManager.cs to set what object is on this tile
    public void SetObjectOnTile(GameObject objOnTile_, TileObjectType type_)
    {
        this.typeOnTile = type_;

        //If no object is added
        if (objOnTile_ == null || type_ == TileObjectType.Nothing)
        {
            this.ResetTile();
        }
        else if (type_ == TileObjectType.Player)
        {
            this.objectOnThisTile = objOnTile_;
            this.SetTileColor(this.playerOccupiedColor);
        }
        else if (type_ == TileObjectType.Enemy)
        {
            this.objectOnThisTile = objOnTile_;
            this.SetTileColor(this.enemyOccupiedColor);
        }
        else if (type_ == TileObjectType.Object)
        {
            this.objectOnThisTile = objOnTile_;
            this.SetTileColor(this.blockedColor);
        }

        this.HighlightTile(false);
    }
コード例 #2
0
 //Function called from CombatTileHandler to reset this tile so there's nothing on it and it's set to the inactive color
 public void ResetTile()
 {
     this.typeOnTile       = TileObjectType.Nothing;
     this.objectOnThisTile = null;
     this.inActionRange    = false;
     this.HighlightTile(false);
     this.hasBeenChecked = false;
 }
コード例 #3
0
 bool IsObjectAllowed(GameObject prefab, int amountOfType, TileObjectType type)
 {
     if (alreadyGeneratedStuff.ContainsKey(prefab.name) == false)
     {
         return(true);
     }
     else
     {
         return(alreadyGeneratedStuff[prefab.name] <= CalculateAllowedAmount(amountOfType, GetAllObjectsOfType(type).Count));
     }
 }
コード例 #4
0
        public static TileObject Parse(XmlElement xmlElement)
        {
            var x  = float.Parse(xmlElement.GetAttribute("x"));
            var y  = float.Parse(xmlElement.GetAttribute("y"));
            var id = int.Parse(xmlElement.GetAttribute("id"));

            if (xmlElement.HasAttribute("width"))
            {
                var width       = float.Parse(xmlElement.GetAttribute("width"));
                var height      = float.Parse(xmlElement.GetAttribute("height"));
                var hasRotation = xmlElement.HasAttribute("rotation");
                var rotation    = hasRotation ? float.Parse(xmlElement.GetAttribute("rotation")) : 0;
                if (xmlElement.HasAttribute("gid"))
                {
                    var gid = int.Parse(xmlElement.GetAttribute("gid"));
                    return(new TileImageObject(id, x, y, width, height, gid));
                }
                return(new TileRectangleObject(id, x, y, width, height, rotation));
            }
            TilePolygon    polygon        = null;
            TileObjectType tileObjectType = TileObjectType.Unknown;

            foreach (XmlElement item in xmlElement.ChildNodes)
            {
                switch (item.Name)
                {
                case "polygon":
                    polygon = new TilePolygon();
                    polygon.Parse(item);
                    tileObjectType = TileObjectType.Polygon;
                    break;

                case "point":
                    tileObjectType = TileObjectType.Point;
                    break;
                }
            }

            switch (tileObjectType)
            {
            case TileObjectType.Polygon:
                return(new TilePolygonObject(id, x, y, polygon));

            case TileObjectType.Point:
                return(new TilePointObject(id, x, y));

            default:
                return(new TileObject(id, x, y));
            }
        }
コード例 #5
0
        GameObject GetRandomObject(TileObjectType type, int amountOfType)
        {
            List <GameObject> returnList = GetAllObjectsOfType(type);
            GameObject        answer     = returnList[Random.Range(0, returnList.Count - 1)];
            int terminator = 0;

            while (IsObjectAllowed(answer, amountOfType, type) == false)
            {
                terminator++;
                returnList.Remove(answer);
                answer = returnList[Random.Range(0, returnList.Count - 1)];
                if (terminator == 100)
                {
                    return(returnList[Random.Range(0, returnList.Count - 1)]);;
                }
            }
            return(answer);
        }
コード例 #6
0
 List <GameObject> GetAllObjectsOfType(TileObjectType type)
 {
     return(allLegalObjects[(int)type].elements);
 }