/// <summary> /// Unity Function. Called once upon creation of the object. /// </summary> void Awake() { if (this.skyBlockParent == null) { this.skyBlockParent = GetComponentInParent <SkyBlock> (); } }
/// <summary> /// Gets the sky block. /// </summary> /// <returns>The sky block.</returns> public SkyBlock GetSkyBlock() { if (this.skyBlock == null) { this.skyBlock = gameObject.GetComponentInChildren <SkyBlock> (); } return(this.skyBlock); }
/// <summary> /// Crafts the sky block according to numerator and denominator but sets it to 1/1. /// </summary> /// <param name="blockParent">Sky Block Game Object</param> /// <param name="numerator">Numerator</param> /// <param name="denominator">Denominator</param> public void InitialCraft(SkyBlock blockParent, float numerator, float denominator) { this.skyBlockParent = blockParent; // TODO: Fixed since this overrides prefilled block settings, check if this holds. this.GetAttachedFragmentBlock().Initialize(this.skyBlockParent, numerator, denominator); this.GetAttachedFragmentBlock().ChangeColor(this.skyBlockParent.GetPieceColor(), this.skyBlockParent.GetPieceOutlineColor()); this.GetAttachedFragmentBlock().SetBlockValues(this.GetAttachedFragmentBlock().GetNumerator(), this.GetAttachedFragmentBlock().GetDenominator()); }
/// <summary> /// Brightness for SkyBlock.Sky is clear white and (through color computing it is assumed) DEPENDENT ON DAYTIME. /// Brightness for SkyBlock.Block is yellowish and independent. /// </summary> public virtual int GetSkyBlockTypeBrightness(SkyBlock par1EnumSkyBlock, int par2, int par3, int par4) { if (par3 < 0) { par3 = 0; } if (par3 >= 256) { par3 = 255; } if (par3 < 0 || par3 >= 256 || par2 < 0xfe363c8 || par4 < 0xfe363c8 || par2 >= 0x1c9c380 || par4 > 0x1c9c380) { return(par1EnumSkyBlock.DefaultLightValue); } if (Block.UseNeighborBrightness[GetBlockId(par2, par3, par4)]) { int i = GetSpecialBlockBrightness(par1EnumSkyBlock, par2, par3 + 1, par4); int k = GetSpecialBlockBrightness(par1EnumSkyBlock, par2 + 1, par3, par4); int i1 = GetSpecialBlockBrightness(par1EnumSkyBlock, par2 - 1, par3, par4); int j1 = GetSpecialBlockBrightness(par1EnumSkyBlock, par2, par3, par4 + 1); int k1 = GetSpecialBlockBrightness(par1EnumSkyBlock, par2, par3, par4 - 1); if (k > i) { i = k; } if (i1 > i) { i = i1; } if (j1 > i) { i = j1; } if (k1 > i) { i = k1; } return(i); } else { int j = (par2 >> 4) - ChunkX; int l = (par4 >> 4) - ChunkZ; return(ChunkArray[j][l].GetSavedLightValue(par1EnumSkyBlock, par2 & 0xf, par3, par4 & 0xf)); } }
public override void TakeHit(Entity source, int damage = 1, DamageCause cause = DamageCause.Unknown) { Player deather = Entity as Player; Player killer = source as Player; Island island; if (killer != null) { if (SkyBlock.IsOp(killer.Username)) { base.TakeHit(source, damage, cause); return; } if (deather != null) { if (killer.KnownPosition.X < -199975 && killer.KnownPosition.X > -199990 && killer.KnownPosition.Z < -199950 && killer.KnownPosition.Z > -199965) { if (deather.KnownPosition.X < -199975 && deather.KnownPosition.X > -199990 && deather.KnownPosition.Z < -199950 && deather.KnownPosition.Z > -199965) { base.TakeHit(source, damage, cause); } else { return; } } else { killer.SendPlayerInventory(); return; } } else if (SkyBlock.Islands.TryGetValue(killer.Username, out island) && Entity.KnownPosition.X < island.Zone.Seckond.X && Entity.KnownPosition.X > island.Zone.First.X && Entity.KnownPosition.Z < island.Zone.Seckond.Z && Entity.KnownPosition.Z > island.Zone.First.Z) { base.TakeHit(source, damage, cause); } else { killer.SendPlayerInventory(); return; } } else { base.TakeHit(source, damage, cause); return; } }
public virtual void Initialize(SkyBlock parent, float numValue, float denValue) { this.skyBlockParent = parent; this.SetBlockSize(skyBlockParent.GetBlockSize()); this.widthWhole = parent.GetWidth(); // Reference the 1 whole size this.widthSingle = (this.widthWhole / denValue) * numValue; // This is the width of this object. // this.widthSingle = (this.widthWhole / this.GetDenominator ())*this.GetNumerator(); // This is the width of this object. this.SetSize(this.widthSingle, this.height); Debug.Log("<color=red>PREV NUM DEN = " + this.GetNumerator() + " " + this.GetDenominator() + "</color>"); if (!isPrefilled) { this.SetNumerator(numValue); this.SetDenominator(denValue); } Debug.Log("<color=red>New NUM DEN = " + this.GetNumerator() + " " + this.GetDenominator() + "</color>"); }
/// <summary> /// Sets the fraction value of the ghost block. /// /// Its value will be added to the stability number line when this is solved. /// </summary> /// <param name="fraction">Fraction</param> /// <param name="block">Referenced Sky Block, if necessary.</param> public void SetFraction(FractionData fraction, SkyBlock block) { this.numerator = fraction.numerator; this.denominator = fraction.denominator; if (block != null) { this.SolvedFromPrefill(); this.fillCount = (int)this.numerator; this.sliceCount = (int)this.denominator; this.skyBlock = block; this.SetPreFilled(true); this.SolvedFromPrefill(); this.BlockProcessOn(); } else { this.SetPreFilled(false); } }
/// <summary> /// 'is only used on stairs and tilled fields' /// </summary> public virtual int GetSpecialBlockBrightness(SkyBlock par1EnumSkyBlock, int par2, int par3, int par4) { if (par3 < 0) { par3 = 0; } if (par3 >= 256) { par3 = 255; } if (par3 < 0 || par3 >= 256 || par2 < 0xfe363c8 || par4 < 0xfe363c8 || par2 >= 0x1c9c380 || par4 > 0x1c9c380) { return(par1EnumSkyBlock.DefaultLightValue); } else { int i = (par2 >> 4) - ChunkX; int j = (par4 >> 4) - ChunkZ; return(ChunkArray[i][j].GetSavedLightValue(par1EnumSkyBlock, par2 & 0xf, par3, par4 & 0xf)); } }
/* * public void SpawnSkyBlocks(int blockCount) { * PurgeSkyBlocks (); * * if (blockCount > 0) { * if (blockCount > placements.Count) * blockCount = placements.Count; * * for (int i = 0; i < blockCount; i++) { * SkyBlock block = Instantiate<SkyBlock> (this.skyblockPrefab); * * block.transform.position = placements [i].position; * block.transform.SetParent (placements [i]); * block.transform.localScale = new Vector2 (1f, 1f); * this.skyBlocks.Add (block); * } * } * } */ /// <summary> /// Coroutine to spawn n number of sky blocks. /// /// Sky blocks spawned cannot exceed the number of placements in the room. /// </summary> /// <param name="blockCount">Requested number of sky blocks to spawn</param> /// <returns>None</returns> public IEnumerator SpawnSkyBlocks(int blockCount) { PurgeSkyBlocks(); if (blockCount > 0) { if (blockCount > placements.Count) { blockCount = placements.Count; } for (int i = 0; i < blockCount; i++) { SkyBlock block = Instantiate <SkyBlock>(this.skyblockPrefab); block.transform.position = placements[i].position; block.transform.SetParent(placements[i]); block.transform.localScale = new Vector2(1f, 1f); this.skyBlocks.Add(block); yield return(null); } } yield return(null); }
public override void Initialize(SkyBlock parent, float numValue, float denValue) { base.Initialize(parent, numValue, denValue); // this.GetFractionBubbleLabel ().UpdateLabel ((int)this.GetNumerator(), (int)this.GetDenominator()); this.detachedManagerParent = this.skyBlockParent.GetDetachedManager(); }
internal EnumSkyBlock(SkyBlock type) { this.Enum = type; }