public Mobility(string id, Image image, double weight, Shape.SHAPES shape, double durability, double remainingDurability, double climbAngle, double maxSpeed, double maxForce) : base(id, image, weight, shape, durability, remainingDurability) { CLIMB_ANGLE = climbAngle; MAX_SPEED = maxSpeed; MAX_FORCE = maxForce; Vector3 rescale = RESCALE.toVector3(); base.GAME_OBJECT.transform.localScale = rescale; }
public void changeTextureAndShape(Texture texture, Mesh mesh, Shape.SHAPES shape) { GAME_OBJECT.GetComponent <Renderer>().material.mainTexture = texture; GAME_OBJECT.GetComponent <MeshFilter>().mesh = mesh; if (shape == Shape.SHAPES.RECTANGULAR_PRISM || shape == Shape.SHAPES.PYRAMID) { Vector2[] uvs = GAME_OBJECT.GetComponent <MeshFilter>().mesh.uv; //front uvs[0] = new Vector2(0.0f, 0.24975f); uvs[1] = new Vector2(0.333f, 0.24975f); uvs[2] = new Vector2(0.0f, 0.333f); uvs[3] = new Vector2(0.333f, 0.333f); //top uvs[4] = new Vector2(0.334f, 0.333f); uvs[5] = new Vector2(0.666f, 0.333f); uvs[8] = new Vector2(0.334f, 0.0f); uvs[9] = new Vector2(0.666f, 0.0f); //back uvs[6] = new Vector2(1.0f, 0.24975f); uvs[7] = new Vector2(0.667f, 0.24975f); uvs[10] = new Vector2(1.0f, 0.333f); uvs[11] = new Vector2(0.667f, 0.333f); //bottom uvs[12] = new Vector2(0.0f, 0.334f); uvs[13] = new Vector2(0.0f, 0.666f); uvs[14] = new Vector2(0.333f, 0.666f); uvs[15] = new Vector2(0.333f, 0.334f); //left uvs[16] = new Vector2(0.334f, 0.334f); uvs[17] = new Vector2(0.334f, 0.41625f); uvs[18] = new Vector2(0.666f, 0.41625f); uvs[19] = new Vector2(0.666f, 0.334f); //right uvs[20] = new Vector2(0.667f, 0.334f); uvs[21] = new Vector2(0.667f, 0.41625f); uvs[22] = new Vector2(1.0f, 0.41625f); uvs[23] = new Vector2(1.0f, 0.334f); GAME_OBJECT.GetComponent <MeshFilter>().mesh.uv = uvs; } }
public Influencer(Dimension size, Shape.SHAPES shape) { this.shape = shape; if (this.shape == Shape.SHAPES.RECTANGULAR_PRISM || this.shape == Shape.SHAPES.PYRAMID) { GAME_OBJECT = GameObject.CreatePrimitive(PrimitiveType.Cube); } else if (this.shape == Shape.SHAPES.HEMISPHERE) { GAME_OBJECT = GameObject.CreatePrimitive(PrimitiveType.Sphere); } else if (this.shape == Shape.SHAPES.CYLINDER) { GAME_OBJECT = GameObject.CreatePrimitive(PrimitiveType.Cylinder); } this.position = new Point(); GAME_OBJECT.AddComponent <Rigidbody>(); GAME_OBJECT.transform.position = this.position.toVector3(); GAME_OBJECT.GetComponent <Collider>().isTrigger = true; if (this.shape != Shape.SHAPES.PYRAMID) { if (size.height == 0) { size.height = DEFAULT_HEIGHT; } else if (size.height == -1) { size.height = Field.FIELD_HEIGHT; } this.size = size; Vector3 obstacleSize = GAME_OBJECT.GetComponent <Collider>().bounds.size; Vector3 rescale = GAME_OBJECT.transform.localScale; rescale.x = (float)this.size.width / GAME_OBJECT.transform.lossyScale.x; rescale.y = (float)this.size.height / GAME_OBJECT.transform.lossyScale.y; rescale.z = (float)this.size.depth / GAME_OBJECT.transform.lossyScale.z; GAME_OBJECT.transform.localScale = rescale; } }
private Obstacle generateObstacleFromObstacleData(ObstacleData obstacleData) { //size Dimension size = new Dimension(obstacleData.width, obstacleData.height, obstacleData.depth); //slope angle int slopeAngle = obstacleData.slopeAngle; //friction double friction = obstacleData.friction; //shape Shape.SHAPES shape = (Shape.SHAPES)Enum.Parse(typeof(Shape.SHAPES), obstacleData.shape, true); //effect Effect <Obstacle> effect; if (obstacleData.effect == null) { effect = null; } else { Type effectType = Type.GetType(obstacleData.effect); ConstructorInfo[] effectConstructorInfo = effectType.GetConstructors(); ParameterInfo[] effectParameters = effectConstructorInfo[0].GetParameters(); object[] parameterValues = generateEffectParameterValues(effectParameters); effect = (Effect <Obstacle>)effectConstructorInfo[0].Invoke(parameterValues); } ConstructorInfo[] obstacleConstructorInfo = Type.GetType(obstacleData.obstacleType).GetConstructors(); Obstacle obstacle = (Obstacle)obstacleConstructorInfo[0].Invoke(new object[] { slopeAngle, friction, size, effect, shape }); //position obstacle = generatePosition(obstacle); obstacle.GAME_OBJECT.GetComponent <Collider>().isTrigger = true; return(obstacle); }
public Head(bool isPreview, string id, Image image, Texture2D icon, double weight, Shape.SHAPES shape, double durability, double remainingDurability) : base(isPreview, id, image, icon, weight, shape, durability, remainingDurability) { }
public Head(string id, Image image, double weight, Shape.SHAPES shape, double durability, double remainingDurability) : base(id, image, weight, shape, durability, remainingDurability) { }
public Body(string id, Image image, double weight, Shape.SHAPES shape, double durability, double remainingDurability, int maxAttachments) : base(id, image, weight, shape, durability, remainingDurability) { MAX_ATTACHMENTS = maxAttachments; }
public Body(bool isPreview, string id, Image image, Texture2D icon, double weight, Shape.SHAPES shape, double durability, double remainingDurability, int maxAttachments) : base(isPreview, id, image, icon, weight, shape, durability, remainingDurability) { MAX_ATTACHMENTS = maxAttachments; }
public Projectile(Robot robot, double velocity, Dimension size, Effect <Projectile> effect, Shape.SHAPES shape, int lifetime) : base(size, shape) { ROBOT = robot; base.GAME_OBJECT.transform.position = new Vector3(0, (float)Field.FIELD_HEIGHT / 2, 0); base.GAME_OBJECT.AddComponent <ProjectileListener>(); if (base.shape == Shape.SHAPES.PYRAMID) { base.shape = Shape.SHAPES.CYLINDER; base.size = size; Vector3 obstacleSize = base.GAME_OBJECT.GetComponent <Renderer>().bounds.size; Vector3 rescale = base.GAME_OBJECT.transform.localScale; rescale.x = (float)size.width * rescale.x / obstacleSize.x; rescale.y = (float)size.height * rescale.y / obstacleSize.y; rescale.z = (float)size.depth * rescale.z / obstacleSize.z; base.GAME_OBJECT.transform.localScale = rescale; } this.effect = effect; if (this.effect != null) { this.effect.bindTo(this); } VELOCITY = velocity; LIFETIME = lifetime; startTime = 0; }
public Obstacle(int slopeAngle, double friction, Dimension size, Effect <Obstacle> effect, Shape.SHAPES shape) : base(size, shape) { SLOPE_ANGLE = slopeAngle; FRICTION = friction; GameObject.Destroy(base.GAME_OBJECT.GetComponent <Collider>()); base.GAME_OBJECT.AddComponent <MeshCollider>().convex = true; base.GAME_OBJECT.AddComponent <ObstacleListener>(); base.GAME_OBJECT.GetComponent <Collider>().material = new PhysicMaterial(); base.GAME_OBJECT.GetComponent <Collider>().material.dynamicFriction = (float)FRICTION; base.GAME_OBJECT.GetComponent <Collider>().material.staticFriction = (float)STATIC_FRICTION_CONST; if (base.shape == Shape.SHAPES.PYRAMID) { GameObject.Destroy(base.GAME_OBJECT.GetComponent <MeshCollider>()); GameObject.Destroy(base.GAME_OBJECT.GetComponent <ObstacleListener>()); this.size = PYRAMID_SIZE; createSlope(); SLOPE_ANGLE = SLOPE_SIZE; } this.effect = effect; if (this.effect != null) { this.effect.bindTo(this); } setConstraints(); }
private Obstacle generateObstacle() { //size double width = RANDOM.NextDouble() * ((double)LIM_VALS[(int)LIMS.MAX_SIZE] + 1 - OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]) + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE] + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]; double height = RANDOM.Next(LIM_VALS[(int)LIMS.MIN_HEIGHT], LIM_VALS[(int)LIMS.MAX_HEIGHT] + 1); double depth = RANDOM.NextDouble() * ((double)LIM_VALS[(int)LIMS.MAX_SIZE] + 1 - OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]) + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE] + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]; Dimension size = new Dimension(width, height, depth); //slope angle double smallestDim = (width < depth) ? width : depth; double slopeWidth = smallestDim / 2 - OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE] / 2; int minSlope = (int)(Math.Atan(height / slopeWidth) + 1); int slopeAngle = RANDOM.Next(minSlope, LIM_VALS[(int)LIMS.MAX_SLOPE_ANGLE] + 1); if (slopeAngle < LIM_VALS[(int)LIMS.MIN_SLOPE_ANGLE]) { slopeAngle = LIM_VALS[(int)LIMS.MIN_SLOPE_ANGLE]; } //friction double friction = RANDOM.NextDouble() * (FRICTION_LIM_VALS[(int)FRICTION_LIMS.MAX_DYNA_FRICTION] + 1 - FRICTION_LIM_VALS[(int)FRICTION_LIMS.MIN_DYNA_FRICTION]) + FRICTION_LIM_VALS[(int)FRICTION_LIMS.MIN_DYNA_FRICTION]; //shape int numberOfShapes = Enum.GetValues(typeof(Shape.SHAPES)).Length; Shape.SHAPES shape = (Shape.SHAPES)Enum.Parse(typeof(Shape.SHAPES), Enum.GetNames(typeof(Shape.SHAPES))[RANDOM.Next(1, numberOfShapes)]); //effect Effect <Obstacle> effect; int effectTypeMaxIndex = EXPERIENCE / LIM_VALS[(int)LIMS.PROGRESS_DAMPER]; List <Type> effectTypes = TypeTools.getTypesOfBaseType(typeof(Effect <Obstacle>)); int numberOfEffectTypes = effectTypes.Count; if (effectTypeMaxIndex >= numberOfEffectTypes) { effectTypeMaxIndex = numberOfEffectTypes - 1; } int effectTypeIndex = RANDOM.Next(effectTypeMaxIndex + 1); if (effectTypeIndex == 0) { effect = null; } else { Type effectType = effectTypes[effectTypeIndex].MakeGenericType(typeof(Obstacle)); ConstructorInfo[] effectConstructorInfo = effectType.GetConstructors(); ParameterInfo[] effectParameters = effectConstructorInfo[0].GetParameters(); object[] parameterValues = generateEffectParameterValues(effectParameters); effect = (Effect <Obstacle>)effectConstructorInfo[0].Invoke(parameterValues); } Obstacle obstacle; int obstacleTypeMaxIndex = EXPERIENCE / LIM_VALS[(int)LIMS.PROGRESS_DAMPER]; List <Type> obstacleTypes = TypeTools.getTypesOfBaseType(typeof(Obstacle)); int numberOfObstacleTypes = obstacleTypes.Count; if (obstacleTypeMaxIndex >= numberOfObstacleTypes) { obstacleTypeMaxIndex = numberOfObstacleTypes - 1; } int obstacleTypeIndex = RANDOM.Next(1, obstacleTypeMaxIndex + 1); Type obstacleType = obstacleTypes[obstacleTypeIndex]; ConstructorInfo[] obstacleConstructorInfo = obstacleType.GetConstructors(); obstacle = (Obstacle)obstacleConstructorInfo[0].Invoke(new object[] { slopeAngle, friction, size, effect, shape }); //position obstacle = generatePosition(obstacle); obstacle.GAME_OBJECT.GetComponent <Collider>().isTrigger = true; return(obstacle); }
public ObstacleData generateObstacleData() { //size double width = RANDOM.NextDouble() * ((double)LIM_VALS[(int)LIMS.MAX_SIZE] + 1 - OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]) + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE] + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]; double height = RANDOM.Next(LIM_VALS[(int)LIMS.MIN_HEIGHT], LIM_VALS[(int)LIMS.MAX_HEIGHT] + 1); double depth = RANDOM.NextDouble() * ((double)LIM_VALS[(int)LIMS.MAX_SIZE] + 1 - OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]) + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE] + OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE]; Dimension size = new Dimension(width, height, depth); //slope angle double smallestDim = (width < depth) ? width : depth; double slopeWidth = smallestDim / 2 - OPERATION_CONSTS_VALS[(int)OPERATION_CONSTS.ROBOT_SCALE] / 2; int minSlope = (int)(Math.Atan(height / slopeWidth) + 1); int slopeAngle = RANDOM.Next(minSlope, LIM_VALS[(int)LIMS.MAX_SLOPE_ANGLE] + 1); if (slopeAngle < LIM_VALS[(int)LIMS.MIN_SLOPE_ANGLE]) { slopeAngle = LIM_VALS[(int)LIMS.MIN_SLOPE_ANGLE]; } //friction double friction = RANDOM.NextDouble() * ((float)FRICTION_LIM_VALS[(int)FRICTION_LIMS.MAX_DYNA_FRICTION] + 1 - FRICTION_LIM_VALS[(int)FRICTION_LIMS.MAX_DYNA_FRICTION]) + FRICTION_LIM_VALS[(int)FRICTION_LIMS.MIN_DYNA_FRICTION]; //shape int numberOfShapes = Enum.GetValues(typeof(Shape.SHAPES)).Length; Shape.SHAPES shape = (Shape.SHAPES)Enum.Parse(typeof(Shape.SHAPES), Enum.GetNames(typeof(Shape.SHAPES))[RANDOM.Next(numberOfShapes)]); //effect Effect <Obstacle> effect; int effectTypeMaxIndex = EXPERIENCE / LIM_VALS[(int)LIMS.PROGRESS_DAMPER]; List <Type> effectTypes = TypeTools.getTypesOfBaseType(typeof(Effect <Obstacle>)); int numberOfEffectTypes = effectTypes.Count; if (effectTypeMaxIndex >= numberOfEffectTypes) { effectTypeMaxIndex = numberOfEffectTypes - 1; } int effectTypeIndex = RANDOM.Next(effectTypeMaxIndex + 1); if (effectTypeIndex == 0) { effect = null; } else { Type effectType = effectTypes[effectTypeIndex].MakeGenericType(typeof(Obstacle)); ConstructorInfo[] constructorInfo = effectType.GetConstructors(); ParameterInfo[] parameters = constructorInfo[0].GetParameters(); object[] parameterValues = new object[parameters.Length]; for (int parameterIndex = 0; parameterIndex < parameters.Length; ++parameterIndex) { Type parameterType = parameters[parameterIndex].ParameterType; object value = default; if (parameterType == typeof(int)) { value = RANDOM.Next(LIM_VALS[(int)LIMS.MIN_MULTIPLIER], LIM_VALS[(int)LIMS.MAX_MULTIPLIER] + 1); } else if (parameterType == typeof(double) || parameterType == typeof(float)) { value = RANDOM.NextDouble() * ((double)LIM_VALS[(int)LIMS.MAX_MULTIPLIER] + 1 - (double)LIM_VALS[(int)LIMS.MIN_MULTIPLIER]) + LIM_VALS[(int)LIMS.MIN_MULTIPLIER]; } parameterValues[parameterIndex] = value; } effect = (Effect <Obstacle>)constructorInfo[0].Invoke(parameterValues); } int obstacleTypeMaxIndex = EXPERIENCE / LIM_VALS[(int)LIMS.PROGRESS_DAMPER]; List <Type> obstacleTypes = TypeTools.getTypesOfBaseType(typeof(Obstacle)); int numberOfObstacleTypes = obstacleTypes.Count; if (obstacleTypeMaxIndex >= numberOfObstacleTypes) { obstacleTypeMaxIndex = numberOfObstacleTypes - 1; } int obstacleTypeIndex = RANDOM.Next(obstacleTypeMaxIndex + 1); Type obstacleType = obstacleTypes[obstacleTypeIndex]; ObstacleData obstacleData = new ObstacleData(); obstacleData.obstacleType = obstacleType.ToString(); obstacleData.width = width; obstacleData.height = height; obstacleData.depth = depth; obstacleData.slopeAngle = slopeAngle; obstacleData.friction = friction; obstacleData.shape = shape.ToString(); if (effect != null) { obstacleData.effect = effect.GetType().ToString(); } return(obstacleData); }
public Part(bool isPreview, string id, Image image, Texture2D icon, double weight, Shape.SHAPES shape, double durability, double remainingDurability) { if (id == default || id == null || id == "" || ((int)id[0]) == 8203) { ID = Guid.NewGuid().ToString(); } else { ID = id; } IMAGE = image; if (IMAGE != null && !isPreview) { IMAGE.setTexture(ImageTools.fixBadColors(IMAGE.getTexture())); } WEIGHT = weight; SHAPE = shape; DURABILITY = durability; this.remainingDurability = remainingDurability; if (IMAGE != null && !isPreview) { if (shape == Shape.SHAPES.RECTANGULAR_PRISM || shape == Shape.SHAPES.PYRAMID) { GAME_OBJECT = GameObject.CreatePrimitive(PrimitiveType.Cube); GAME_OBJECT.GetComponent <Renderer>().material.mainTexture = IMAGE.getTexture(); Vector2[] uvs = GAME_OBJECT.GetComponent <MeshFilter>().mesh.uv; //front uvs[0] = new Vector2(0.0f, 0.24975f); uvs[1] = new Vector2(0.333f, 0.24975f); uvs[2] = new Vector2(0.0f, 0.333f); uvs[3] = new Vector2(0.333f, 0.333f); //top uvs[4] = new Vector2(0.334f, 0.333f); uvs[5] = new Vector2(0.666f, 0.333f); uvs[8] = new Vector2(0.334f, 0.0f); uvs[9] = new Vector2(0.666f, 0.0f); //back uvs[6] = new Vector2(1.0f, 0.24975f); uvs[7] = new Vector2(0.667f, 0.24975f); uvs[10] = new Vector2(1.0f, 0.333f); uvs[11] = new Vector2(0.667f, 0.333f); //bottom uvs[12] = new Vector2(0.0f, 0.334f); uvs[13] = new Vector2(0.0f, 0.666f); uvs[14] = new Vector2(0.333f, 0.666f); uvs[15] = new Vector2(0.333f, 0.334f); //left uvs[16] = new Vector2(0.334f, 0.334f); uvs[17] = new Vector2(0.334f, 0.41625f); uvs[18] = new Vector2(0.666f, 0.41625f); uvs[19] = new Vector2(0.666f, 0.334f); //right uvs[20] = new Vector2(0.667f, 0.334f); uvs[21] = new Vector2(0.667f, 0.41625f); uvs[22] = new Vector2(1.0f, 0.41625f); uvs[23] = new Vector2(1.0f, 0.334f); GAME_OBJECT.GetComponent <MeshFilter>().mesh.uv = uvs; } else if (shape == Shape.SHAPES.HEMISPHERE) { GAME_OBJECT = GameObject.CreatePrimitive(PrimitiveType.Sphere); GAME_OBJECT.GetComponent <Renderer>().material.mainTexture = IMAGE.getTexture(); } else if (shape == Shape.SHAPES.CYLINDER) { GAME_OBJECT = GameObject.CreatePrimitive(PrimitiveType.Cylinder); GAME_OBJECT.GetComponent <Renderer>().material.mainTexture = IMAGE.getTexture(); } position = new Point(); GAME_OBJECT.GetComponent <Renderer>().material.shader = Shader.Find("Unlit/Texture"); GAME_OBJECT.GetComponent <Collider>().isTrigger = false; if (!(this is Attachment)) { this.icon = null; } else { this.icon = IMAGE.getTexture(); } } else { GAME_OBJECT = default; if (!(this is Attachment)) { this.icon = icon; } else { this.icon = IMAGE.getTexture(); } } }
public Blaster(bool isPreview, string id, Image image, double weight, Effect <Robot> effect, Shape.SHAPES shape, double durability, double remainingDurability, int minChargeTime, int maxChargeTime, int minCoolingTime, double maxDamage) : base(isPreview, id, image, weight, null, shape, durability, remainingDurability, minChargeTime, maxChargeTime, 0, minCoolingTime, maxDamage, WEAPON, PASSIVE, INVISIBLE) { }
public Attachment(bool isPreview, string id, Image image, double weight, Effect <Attachment> effect, Shape.SHAPES shape, double durability, double remainingDurability, int minChargeTime, int maxChargeTime, int maxUsageTime, int minCoolingTime, double maxDamage, bool weapon, bool passive, bool invisible) : base(isPreview, id, image, image.getTexture(), weight, shape, durability, remainingDurability) { EFFECT = effect; MIN_CHARGE_TIME = minChargeTime; MAX_CHARGE_TIME = maxChargeTime; MAX_USAGE_TIME = maxUsageTime; MIN_COOLING_TIME = minCoolingTime; MAX_DAMAGE = maxDamage; WEAPON = weapon; PASSIVE = passive; INVISIBLE = invisible; chargeStartTime = 0; usageStartTime = 0; coolingStartTime = 0; coolingTimeNeeded = 0; inUse = false; if (!isPreview) { base.destroyGameObject(); } }
public Block(int slopeAngle, double friction, Dimension size, Effect <Obstacle> effect, Shape.SHAPES shape) : base(slopeAngle, friction, size, effect, shape) { }