コード例 #1
0
ファイル: GridManager.cs プロジェクト: wolframit/BA_Unity
    public Platform GetPlatformForHighlight(Vector3 pos, Vector3 dir, int buildingOp)
    {
        outPlatform = null;

        direction = OrthoDirections.GetDirFromLookDirection(pos, dir);

        direction *= PlatformEdgeSize;

        //Debug.Log("newPlat:" + (pos + direction));

        //foreach (var item in Grid)
        //{
        //    //Debug.Log(item.Key);
        //}
        key = new HashableVector(pos + direction);

        Grid.TryGetValue(key, out outPlatform);

        //if(Grid.ContainsKey(key))
        //{
        //    outPlatform = Grid[key];
        //}
        //else
        //{
        //    outPlatform = null;
        //}

        if (outPlatform == null)
        {
            tempPlat    = Instantiate <GameObject>(PlatformObject, DataPipe.instance.PlatformHolder.transform);
            outPlatform = tempPlat.GetComponent <Platform>();
            Grid.Add(key, outPlatform);
            tempPlat.transform.localPosition = key.GetVector();
            tempVec       = tempPlat.transform.localPosition / PlatformEdgeSize;
            tempPlat.name = "Platform ( " + tempVec.x + " | " + tempVec.z + " )  Type: " + buildingOp;

            _validPlatforms = Grid.Values.Where((p) => p.Activated && !p.IsHQ).ToList();
        }

        return(outPlatform);
    }
コード例 #2
0
ファイル: GridManager.cs プロジェクト: wolframit/BA_Unity
    public override bool Equals(object obj)
    {
        if (ReferenceEquals(this, obj))
        {
            return(true);
        }

        HashableVector other = obj as HashableVector;

        if (ReferenceEquals(null, other))
        {
            return(false);
        }

        if (other.x == this.x && other.y == this.y && other.z == this.z)
        {
            return(true);
        }

        return(false);
    }