public Knife(string type, int cost, enColor cl) { Type = type; Cost = cost; Color = cl; price += cost; }
public override void initInstance(enType type, enColor color, bool isPlayer) { base.initInstance(type, color, true); // The player position is always static, so set it this.transform.position = new Vector3(PersonBrain.minHorPosition, 0.0f, 0.0f); forceStop(); this.gameObject.SetActive(true); this.isRunningAI = true; }
private IEnumerator fadeToWhite() { while (this.sprBody != null && this.sprBody.color != Color.white) { float b = this.sprBody.color.b; float g = this.sprBody.color.g; float r = this.sprBody.color.r; if (r < 1.0f) { r += Time.deltaTime; if (r > 1.0f) { r = 1.0f; } } if (g < 1.0f) { g += Time.deltaTime; if (g > 1.0f) { g = 1.0f; } } if (b < 1.0f) { b += Time.deltaTime; if (b > 1.0f) { b = 1.0f; } } this.sprBody.color = new Color(r, g, b); yield return null; } // Update the required people count if (this.state != enState.bribed) { PersonBrain.lvlManager.currentFollowers++; } }
/** * Return all colors this person has influence over */ public bool sufferInfluence(enColor color) { switch (this.color) { case enColor.magenta: return color == enColor.magenta || color == enColor.red || color == enColor.blue || color == enColor.black; case enColor.cyan: return color == enColor.cyan || color == enColor.blue || color == enColor.green || color == enColor.black; case enColor.yellow: return color == enColor.yellow || color == enColor.green || color == enColor.red || color == enColor.black; case enColor.red: return color == enColor.red || color == enColor.black; case enColor.green: return color == enColor.green || color == enColor.black; case enColor.blue: return color == enColor.blue || color == enColor.black; case enColor.black: return color == enColor.black; default: return false; } }
/** * Return all colors this person has influence over */ public bool isFriendColor(enColor color) { switch (this.color) { case enColor.magenta: return color == enColor.magenta; case enColor.cyan: return color == enColor.cyan; case enColor.yellow: return color == enColor.yellow; case enColor.red: return color == enColor.red || color == enColor.magenta || color == enColor.yellow; case enColor.green: return color == enColor.green || color == enColor.yellow || color == enColor.cyan; case enColor.blue: return color == enColor.blue || color == enColor.cyan || color == enColor.magenta; case enColor.black: return true; default: return false; } }
/** * Initialize a interactive instance * * @param type The type of the person * @param color The color of the person */ public virtual void initInstance(enType type, enColor color, bool isPlayer = false) { Color32 c32; // Set the instance's properties this.type = type; this.color = color; // Make sure this person can be bribed/influenced this.state = enState.free; this.isWhite = false; this.dir = enDir.none; // Always start on idle forceAIState(enAIState.idle); this.sprBody = null; this.fixLayer = this.GetComponentInChildren<FixLayer>(); if (this.fixLayer != null) { this.fixLayer.fixLayer(this, isPlayer); this.sprBody = this.fixLayer.getBody(); } switch(type) { case enType.level_0: this.fixLayer.setType(0); break; case enType.level_1: this.fixLayer.setType(1); break; case enType.level_2: this.fixLayer.setType(2); break; } switch (this.color) { case enColor.red: c32 = new Color32(0xed, 0x6a, 0x6a, 0xff); break; case enColor.green: c32 = new Color32(0x3e, 0xb7, 0x79, 0xff); break; case enColor.blue: c32 = new Color32(0x54, 0x57, 0x9e, 0xff); break; case enColor.magenta: c32 = new Color32(0xda, 0x71, 0xb0, 0xff); break; case enColor.cyan: c32 = new Color32(0x69, 0xb6, 0xd3, 0xff); break; case enColor.yellow: c32 = new Color32(0xe1, 0xda, 0x4f, 0xff); break; case enColor.black: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; case enColor.white: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; default: c32 = new Color32(0xff, 0xff, 0xff, 0xff); break; } if (this.sprBody) { this.sprBody.color = new Color((float)c32.r / 255.0f, (float)c32.g / 255.0f, (float)c32.b / 255.0f); } // Randomize the position this.transform.position = new Vector3(Random.Range( PersonBrain.minHorPosition + 0.5f, PersonBrain.maxHorPosition - 0.5f), 0, 0); // Activate the object's physics/behavious/etc this.gameObject.SetActive(true); }