Ejemplo n.º 1
0
    protected virtual void CreateCastedSpellGhost()
    {
        this.InterpreterContext.Clear();
        this.InterpreterContext.Register("SpellDefinitionName", this.SpellDefinition.Name);
        GameObject gameObject = this.WorldEntityMappingService.Instantiate(null, "CastedSpellGhost", this.InterpreterContext);

        if (gameObject != null)
        {
            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject);
            if (gameObject2 != null && base.WorldEncounter != null)
            {
                WorldPatch worldPatch = base.GlobalPositionningService.GetWorldPatch(WorldCursor.HighlightedWorldPosition);
                if (worldPatch == null)
                {
                    return;
                }
                gameObject2.SetActive(true);
                gameObject2.transform.parent   = worldPatch.RootedTransform;
                gameObject2.transform.position = base.GlobalPositionningService.Get3DPosition(WorldCursor.HighlightedWorldPosition);
                base.WorldEncounter.RegisterCastedSpellGhost(gameObject2);
            }
            UnityEngine.Object.Destroy(gameObject);
            this.SetWorldAreaHexagonRendererPosition(gameObject2, WorldCursor.HighlightedWorldPosition, true);
        }
    }
Ejemplo n.º 2
0
    private void GenerateBattleZone(WorldPosition attackerPosition, WorldOrientation orientation)
    {
        World world = (base.GameService.Game as global::Game).World;
        IGlobalPositionningService globalPositionningService = null;

        if (globalPositionningService == null)
        {
            WorldView worldView = Services.GetService <Amplitude.Unity.View.IViewService>().CurrentView as WorldView;
            if (worldView != null && worldView.CurrentWorldViewTechnique != null)
            {
                globalPositionningService = worldView.CurrentWorldViewTechnique.Services.GetService <IGlobalPositionningService>();
            }
        }
        if (!attackerPosition.IsValid)
        {
            return;
        }
        WorldPosition  worldPosition  = attackerPosition;
        DeploymentArea deploymentArea = new DeploymentArea(worldPosition, orientation, world.WorldParameters);

        deploymentArea.Initialize(this.DeploymentAreaWidth, this.DeploymentAreaDepth);
        WorldArea        worldArea       = new WorldArea(deploymentArea.GetWorldPositions(world.WorldParameters));
        WorldOrientation forward         = orientation.Rotate(3);
        DeploymentArea   deploymentArea2 = new DeploymentArea(WorldPosition.GetNeighbourTile(worldPosition, orientation, 1), forward, world.WorldParameters);

        deploymentArea2.Initialize(this.DeploymentAreaWidth, this.DeploymentAreaDepth);
        WorldArea worldArea2 = new WorldArea(deploymentArea2.GetWorldPositions(world.WorldParameters));
        WorldArea worldArea3 = new WorldArea(worldArea.Grow(world.WorldParameters));

        worldArea3 = worldArea3.Union(worldArea2.Grow(world.WorldParameters));
        WorldPatch worldPatch = globalPositionningService.GetWorldPatch(attackerPosition);

        this.GenerateGeometry(worldPatch, attackerPosition, worldArea3, worldArea, worldArea2);
    }
    private void CreateCreepingNodeHexFidsIFN()
    {
        if (this.worldEntityHelperContent != null)
        {
            return;
        }
        WorldView worldView = base.ViewService.CurrentView as WorldView;
        DefaultWorldViewTechnique defaultWorldViewTechnique = worldView.CurrentWorldViewTechnique as DefaultWorldViewTechnique;

        if (defaultWorldViewTechnique == null)
        {
            return;
        }
        GameObject gameObject = null;

        if (!this.WorldEntityFactoryService.TryGetValue(this.Node.PointOfInterest.GUID, out gameObject))
        {
            return;
        }
        WorldPatch worldPatch = null;
        Transform  parent     = gameObject.transform.parent;

        while (worldPatch == null && parent != null)
        {
            worldPatch = parent.GetComponent <WorldPatch>();
            parent     = parent.parent;
        }
        if (worldPatch == null)
        {
            return;
        }
        AbstractTerrainPatchRenderer abstractTerrainPatchRenderer = null;
        bool flag = worldPatch.TryGetPatchRenderer <AbstractTerrainPatchRenderer>(out abstractTerrainPatchRenderer);

        if (!flag || abstractTerrainPatchRenderer == null)
        {
            return;
        }
        this.worldEntityHelperContent = new WorldEntityHelper.WorldEntityHelperContent();
        InstanciedMeshBlock orCreateInstanciedMeshBlock  = this.worldEntityHelperContent.GetOrCreateInstanciedMeshBlock(defaultWorldViewTechnique.HxTechniqueGraphicData.InstanciedMeshHolders, PrimitiveLayerMask.Fids, InstanciedMeshHelpers.PositionForwardScaleZPixelsPerInstance);
        InstanciedMeshBlock orCreateInstanciedMeshBlock2 = this.worldEntityHelperContent.GetOrCreateInstanciedMeshBlock(defaultWorldViewTechnique.HxTechniqueGraphicData.InstanciedMeshHolders, PrimitiveLayerMask.Fids, InstanciedMeshHelpers.PositionTexCoordWorldScaleTextureScalePixelsPerInstance);

        for (int i = 0; i < this.WorldArea.WorldPositions.Count; i++)
        {
            Vector3 absoluteWorldPosition2D = abstractTerrainPatchRenderer.GlobalPositionningService.GetAbsoluteWorldPosition2D(this.WorldArea.WorldPositions[i]);
            absoluteWorldPosition2D.x -= abstractTerrainPatchRenderer.OffsetX;
            absoluteWorldPosition2D.z -= abstractTerrainPatchRenderer.OffsetZ;
            InstancingHelper.SpawnOnePrefab(abstractTerrainPatchRenderer, defaultWorldViewTechnique, defaultWorldViewTechnique.HxTechniqueGraphicData.AllResourceFidsGraphicDatas.CityExploitationHexaData, absoluteWorldPosition2D, (int)this.WorldArea.WorldPositions[i].Row, (int)this.WorldArea.WorldPositions[i].Column, null, PrimitiveLayerMask.Fids, ref orCreateInstanciedMeshBlock, PrimitiveLayerMask.Fids, ref orCreateInstanciedMeshBlock2, false, 0, 0);
        }
        this.worldEntityHelperContent.CloseInstanciedMeshBlockIFN(abstractTerrainPatchRenderer);
        this.worldEntityHelperContent.Show();
    }
Ejemplo n.º 4
0
    protected void WorldCursor_HighlightedWorldPositionChange(object sender, HighlightedWorldPositionChangeEventArgs e)
    {
        if (base.WorldEncounter == null || base.WorldEncounter.Encounter == null || base.WorldEncounter.Encounter.BattleZone == null)
        {
            return;
        }
        bool flag = base.WorldEncounter.Encounter.BattleZone.Contains(e.WorldPosition);

        if (this.SpellCursor != null)
        {
            WorldPatch worldPatch = base.GlobalPositionningService.GetWorldPatch(WorldCursor.HighlightedWorldPosition);
            if (worldPatch == null)
            {
                return;
            }
            this.SpellCursor.SetActive(true);
            this.SpellCursor.transform.parent   = worldPatch.RootedTransform;
            this.SpellCursor.transform.position = base.GlobalPositionningService.Get3DPosition(WorldCursor.HighlightedWorldPosition);
            Renderer[] componentsInChildren = this.SpellCursor.GetComponentsInChildren <Renderer>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                if (flag)
                {
                    for (int j = 0; j < componentsInChildren[i].materials.Length; j++)
                    {
                        if (componentsInChildren[i].materials[j].HasProperty("_TintColor0"))
                        {
                            Color color = componentsInChildren[i].materials[j].GetColor("_TintColor0");
                            componentsInChildren[i].materials[j].SetColor("_TintColor", color);
                        }
                    }
                }
                else
                {
                    for (int k = 0; k < componentsInChildren[i].materials.Length; k++)
                    {
                        if (componentsInChildren[i].materials[k].HasProperty("_TintColor1"))
                        {
                            Color color2 = componentsInChildren[i].materials[k].GetColor("_TintColor1");
                            componentsInChildren[i].materials[k].SetColor("_TintColor", color2);
                        }
                    }
                }
            }
            this.SetWorldAreaHexagonRendererPosition(this.SpellCursor, WorldCursor.HighlightedWorldPosition, false);
        }
    }
Ejemplo n.º 5
0
 private void GenerateGeometry(WorldPatch patchParent, WorldPosition attackerPosition, WorldArea battleArea, WorldArea attackerDeploymentArea, WorldArea defenderDeploymentArea)
 {
     if (this.battleZoneGameObject == null)
     {
         this.battleZoneGameObject         = new GameObject("BattleArea");
         this.battleDeploymentAreaAttacker = this.InstantiateGameObjectFromPrefabNameAndInitMeshFilter("Prefabs/Encounters/ArmyWorldCursorDeploymentArea", this.battleZoneGameObject, false);
         this.battleDeploymentAreaDefender = this.InstantiateGameObjectFromPrefabNameAndInitMeshFilter("Prefabs/Encounters/ArmyWorldCursorDeploymentArea", this.battleZoneGameObject, false);
         this.battleAreaBoundary           = this.InstantiateGameObjectFromPrefabNameAndInitMeshFilter("Prefabs/Encounters/ArmyWorldCursorEncounterBoundary", this.battleZoneGameObject, false);
     }
     this.battleZoneGameObject.transform.parent        = patchParent.RootedTransform;
     this.battleZoneGameObject.transform.localPosition = new Vector3(0f, 0.005f, 0f);
     if (this.battleAreaBoundary != null)
     {
         this.battleAreaBoundary.transform.localPosition = Vector3.zero;
         WorldAreaHexagonRenderer component = this.battleAreaBoundary.GetComponent <WorldAreaHexagonRenderer>();
         component.SetWorldArea(battleArea, attackerPosition, base.GlobalPositionningService);
         component.SetMaterialSelectionStatus(false, true, true);
     }
     if (this.battleDeploymentAreaAttacker != null)
     {
         this.battleDeploymentAreaAttacker.transform.localPosition = new Vector3(0f, 0.005f, 0f);
         WorldAreaHexagonRenderer component2 = this.battleDeploymentAreaAttacker.GetComponent <WorldAreaHexagonRenderer>();
         component2.SetWorldArea(attackerDeploymentArea, attackerPosition, base.GlobalPositionningService);
         Color color = this.WorldArmy.Army.Empire.Color;
         color.a = this.attackerAlphaValue;
         component2.SetColor(color);
         component2.SetMaterialSelectionStatus(false, true, true);
     }
     if (this.battleDeploymentAreaDefender != null)
     {
         this.battleDeploymentAreaDefender.transform.localPosition = new Vector3(0f, 0.005f, 0f);
         WorldAreaHexagonRenderer component3 = this.battleDeploymentAreaDefender.GetComponent <WorldAreaHexagonRenderer>();
         component3.SetWorldArea(defenderDeploymentArea, attackerPosition, base.GlobalPositionningService);
         Color color2 = new Color(1f, 0f, 0f, this.defenderAlphaValue);
         if (this.battleTarget is Garrison)
         {
             Garrison garrison = this.battleTarget as Garrison;
             if (garrison.Empire != null)
             {
                 color2 = garrison.Empire.Color;
                 Army army = garrison as Army;
                 if (army != null && army.IsPrivateers)
                 {
                     IPlayerControllerRepositoryService service = Services.GetService <IGameService>().Game.Services.GetService <IPlayerControllerRepositoryService>();
                     if (service.ActivePlayerController != null && service.ActivePlayerController.Empire != null && service.ActivePlayerController.Empire.Index != garrison.Empire.Index)
                     {
                         color2 = global::Game.PrivateersColor;
                     }
                 }
                 color2.a = this.defenderAlphaValue;
             }
         }
         else if (this.battleTarget is District)
         {
             color2 = ((District)this.battleTarget).Empire.Color;
         }
         component3.SetColor(color2);
         component3.SetMaterialSelectionStatus(false, true, true);
     }
     this.battleZoneGameObject.SetActive(true);
     this.battleZoneVisible = true;
 }