示例#1
0
        /// <summary>Moves the provided <see cref="Debris"/> to the nearest player.</summary>
        /// <param name="debris">The debris to move out of water.</param>
        private static void TeleportDebrisOutOfWater(GameLocation location, Debris debris)
        {
            if (location == null || debris == null) //if the location and/or debris is null
            {
                return;                             //do nothing
            }
            foreach (Chunk chunk in debris.Chunks)  //for each chunk of this debris
            {
                Farmer nearestPlayer         = null;
                float  nearestPlayerDistance = 0;

                foreach (Farmer player in location.farmers)                                    //for each player at this location
                {
                    float distance = (player.Position - chunk.position.Value).LengthSquared(); //get the distance between this player and the chunk

                    if (nearestPlayer == null || distance < nearestPlayerDistance)             //if this is the first player OR the nearest player so far
                    {
                        nearestPlayer         = player;                                        //update the nearest player
                        nearestPlayerDistance = distance;                                      //update the nearest player's distance
                    }
                }

                if (nearestPlayer != null)                                //if any player was selected (i.e. there are any players at this location)
                {
                    chunk.position.Value = nearestPlayer.Position;        //move this chunk to the nearest player's position
                    chunk.position.UpdateExtrapolation(chunk.getSpeed()); //update NetPosition data (note: this fixes behavioral issues in multiplayer & appears benign in other contexts)
                }
            }
        }
示例#2
0
        public override bool performToolAction(Tool t, GameLocation location)
        {
            //Debug.Log($"{name} Bot.performToolAction({t}, {location})");

            if (t is Pickaxe or Axe or Hoe)
            {
                //Debug.Log("{name} Bot.performToolAction: creating custom debris");
                var who = t.getLastFarmerToUse();
                this.performRemoveAction(this.TileLocation, location);
                Debris deb = new Debris(this.getOne(), who.GetToolLocation(), new Vector2(who.GetBoundingBox().Center.X, who.GetBoundingBox().Center.Y));
                SetModData(deb.item.modData);
                Game1.currentLocation.debris.Add(deb);
                //Debug.Log($"{name} Created debris with item {deb.item} and energy {energy}");
                // Remove, stop, and destroy this bot
                Game1.currentLocation.overlayObjects.Remove(this.TileLocation);
                if (shell != null)
                {
                    shell.interpreter.Stop();
                }
                instances.Remove(this);
                return(false);
            }

            // previous code, that called the base... this sometimes resulted
            // in picking up a chest, while leaving a ghost bot behind:
            //bool result = base.performToolAction(t, location);
            //Debug.Log($"{name} Bot.performToolAction: My TileLocation is now {this.TileLocation}");
            //return result;
            // I'm not aware of any use case for doing the default tool action on a bot.
            // So now we're going to avoid that whole issue by always doing:
            return(false);
        }
        private static bool Debris_collect_Prefix(Debris __instance, ref bool __result, NetObjectShrinkList <Chunk> ___chunks, Farmer farmer, Chunk chunk)
        {
            if (chunk == null)
            {
                if (___chunks.Count <= 0)
                {
                    return(false);
                }
                chunk = ___chunks[0];
            }

            if (!customChestTypesDict.ContainsKey(chunk.debrisType) && !customChestTypesDict.ContainsKey(-chunk.debrisType))
            {
                return(true);
            }

            SMonitor.Log($"collecting {chunk.debrisType}");

            if (farmer.addItemToInventoryBool(new Object(Vector2.Zero, -chunk.debrisType, false), false))
            {
                __result = true;
                return(false);
            }
            return(true);
        }
示例#4
0
    IEnumerator GenerateTrashDebris(int level)
    {
        List <Debris> trash = new List <Debris>();

        if (trash.Count > 0)
        {
            throw new UnityException("Trash was not empty");
        }

        Debris.trash = new List <Debris>();
        for (int i = 0; i < trash_debris_num[level]; i++)
        {
            Debris d = Instantiate(debris_prefab);
            d.persistent = false;

            trash.Add(d);
        }

        Debris.trash.AddRange(trash);

        foreach (Debris d in trash)
        {
            d.Initialize();
            yield return(new WaitForSeconds(generate_delay[level] / 2f));;
            d.Fly();
        }
        trash_routine = null;
    }
示例#5
0
    void Start()
    {
        InvokeRepeating("GenRock", 1, 0.1f);
        // jsopnの読み込み
        TextAsset textasset = new TextAsset();

        textasset = Resources.Load("deb", typeof(TextAsset)) as TextAsset;
        debrises  = JsonUtility.FromJson <Debris>(textasset.text);
        //Debug.Log("Launch site:"+debrises.DEBRIS[1].LAUNCH_SITE);
        //Debug.Log("Object name:" + debrises.DEBRIS[1].OBJECT_NAME);
        //Debug.Log("period:" + debrises.DEBRIS[1].PERIOD);
        //Debug.Log("owner:" + debrises.DEBRIS[1].OWNER);


        //Debug.Log(debrises.DEBRIS.Length);
        this.Debris_ID          = Mathf.FloorToInt(Random.value * debrises.DEBRIS.Length);
        this.Debris_type        = debrises.DEBRIS[this.Debris_ID].OBJECT_TYPE;
        this.Debris_name        = debrises.DEBRIS[this.Debris_ID].OBJECT_NAME;
        this.Debris_owner       = debrises.DEBRIS[this.Debris_ID].OPERATIONAL_STATUS;
        this.Debris_launch_site = debrises.DEBRIS[this.Debris_ID].LAUNCH_SITE;


        //Debug.Log(Debris_type);

        InvokeRepeating("GenPay", 1, 5.0f);
    }
示例#6
0
    public Debris Alloc()
    {
        Assert(IsPrefab);

        Debris result;

        if (next != null)
        {
            // RECYCLE INSTANCE
            result      = next;
            next        = result.next;
            result.next = null;
            result.gameObject.SetActive(true);
        }
        else
        {
            // CREATE NEW INSTANCE
            result        = Dup(this);
            result.prefab = this;
        }

        // RE-INIT INSTANCE
        result.Init();
        return(result);
    }
 public override bool performToolAction(Tool t, GameLocation location)
 {
     if (t is Pickaxe)
     {
         var who = t.getLastFarmerToUse();
         this.performRemoveAction(this.TileLocation, location);
         Debris deb = new Debris(getOne(), who.GetToolLocation(), new Vector2(who.GetBoundingBox().Center.X, who.GetBoundingBox().Center.Y));
         Game1.currentLocation.debris.Add(deb);
         DataAccess  DataAccess = DataAccess.GetDataAccess();
         List <Node> nodes      = DataAccess.LocationNodes[Game1.currentLocation];
         Node        node       = nodes.Find(n => n.Position.Equals(TileLocation));
         if (node != null && node is ConnectorPipeNode)
         {
             ConnectorPipeNode pipe = (ConnectorPipeNode)node;
             if (pipe.StoredItem != null)
             {
                 Printer.Info($"[T{Thread.CurrentThread.ManagedThreadId}] GET OUT");
                 Printer.Info($"[T{Thread.CurrentThread.ManagedThreadId}] " + pipe.StoredItem.Stack.ToString());
                 pipe.Print();
                 Debris itemDebr = new Debris(pipe.StoredItem, who.GetToolLocation(), new Vector2(who.GetBoundingBox().Center.X, who.GetBoundingBox().Center.Y));
                 Game1.currentLocation.debris.Add(itemDebr);
                 pipe.Broken = true;
             }
         }
         Game1.currentLocation.objects.Remove(this.TileLocation);
         return(false);
     }
     return(false);
 }
    public void StartMinigame()
    {
        int    randomIndex  = Random.Range(0, debrisList.Count);
        Debris activeDebris = debrisList[randomIndex];

        activeDebris.Spawn();
    }
示例#9
0
        public static void createObjectDebris(Item I, int xTileOrigin, int yTileOrigin, int xTileTarget, int yTileTarget, int groundLevel = -1, int itemQuality = 0, float velocityMultiplyer = 1f, GameLocation location = null)
        {
            Debris debris = new Debris(I, new Vector2(xTileOrigin, yTileOrigin), new Vector2(xTileTarget, yTileTarget))
            {
                itemQuality = itemQuality,
            };

            /*
             * Debris debris = new Debris(objectIndex, new Vector2((float)(xTile * Game1.tileSize + Game1.tileSize / 2), (float)(yTile * Game1.tileSize + Game1.tileSize / 2)), new Vector2((float)Game1.player.getStandingX(), (float)Game1.player.getStandingY()))
             * {
             *  itemQuality = itemQuality
             * };
             */
            foreach (Chunk chunk in debris.Chunks)
            {
                double num1 = (double)chunk.xVelocity * (double)velocityMultiplyer;
                chunk.xVelocity = (float)num1;
                double num2 = (double)chunk.yVelocity * (double)velocityMultiplyer;
                chunk.yVelocity = (float)num2;
            }
            if (groundLevel != -1)
            {
                debris.chunkFinalYLevel = groundLevel;
            }
            (location == null ? Game1.currentLocation : location).debris.Add(debris);
        }
示例#10
0
    /// <summary>
    /// Start is called on the frame when a script is enabled just before
    /// any of the Update methods is called the first time.
    /// </summary>

    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "hidenTile")
        {
            return;
        }
        else
        {
            /*break tag for breakable object */
            if (other.tag == "enmy" || other.tag == "break" || other.tag == "deadly")
            {
                GameObject efc = Instantiate(Effect, transform.position, Quaternion.identity) as GameObject;
                efc.transform.localScale = new Vector3(1 * transform.localScale.x, 1, 1);
                Destroy(this.gameObject);
            }
            else if (other.tag == "solid")
            {
                Rigidb = GetComponent <Rigidbody2D>();
                //debris le cvript qui me permet detre insparant
                debris          = GetComponent <Debris>();
                Rigidb.velocity = new Vector2(0, 0);
                debris.enabled  = true;
            }
        }
    }
示例#11
0
        public void DebrisHasMoved(Debris debrisThatHasMoved)
        {
            Contract.Requires(debrisThatHasMoved != null);

            // we were called by space, that sthg has happend
            Check4Alert();
        }
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("HealthPercentage", true, out subEle);
            subEle.Value = HealthPercentage.ToString();

            ele.TryPathTo("Index", true, out subEle);
            subEle.Value = Index.ToString();

            ele.TryPathTo("Stage", true, out subEle);
            subEle.Value = Stage.ToString();

            ele.TryPathTo("Flags", true, out subEle);
            subEle.Value = Flags.ToString();

            ele.TryPathTo("SelfDamagePerSecond", true, out subEle);
            subEle.Value = SelfDamagePerSecond.ToString();

            ele.TryPathTo("Explosion", true, out subEle);
            Explosion.WriteXML(subEle, master);

            ele.TryPathTo("Debris", true, out subEle);
            Debris.WriteXML(subEle, master);

            ele.TryPathTo("DebrisCount", true, out subEle);
            subEle.Value = DebrisCount.ToString();
        }
示例#13
0
        private void DropCargoToken()
        {
            Action Callback = Phases.CurrentSubPhase.CallBack;

            DecisionSubPhase.ConfirmDecisionNoCallback();

            HostUpgrade.State.SpendCharge();

            ManeuverTemplate dropTemplate = new ManeuverTemplate(ManeuverBearing.Straight, ManeuverDirection.Forward, ManeuverSpeed.Speed1, isBombTemplate: true);

            dropTemplate.ApplyTemplate(HostShip, HostShip.GetBack(), Direction.Bottom);

            Debris looseCargo = new Debris("Loose Cargo", "loosecargo");

            looseCargo.Spawn("Loose Cargo " + HostShip.ShipId, Board.GetBoard());
            ObstaclesManager.AddObstacle(looseCargo);

            looseCargo.ObstacleGO.transform.position    = dropTemplate.GetFinalPosition();
            looseCargo.ObstacleGO.transform.eulerAngles = dropTemplate.GetFinalAngles();
            looseCargo.IsPlaced = true;

            GameManagerScript.Wait(
                1,
                delegate
            {
                dropTemplate.DestroyTemplate();
                Callback();
            }
                );
        }
示例#14
0
 void DoSplit()
 {
     if (radius > minRadius)
     {
         float rang = Random.value * 360;
         float rad  = Mathf.Sqrt((radius * radius) / splitCount) * splitRadiusBoost;
         for (int i = 0; i < splitCount; i++)
         {
             GameObject go = GameObject.Instantiate(splitPrefab, transform.position, transform.rotation);
             go.tag = this.tag;
             Debris deb = go.GetComponent <Debris>();
             deb.radius          = rad;
             deb.vel             = vel + Quaternion.AngleAxis(rang + i * (360 / splitCount), Vector3.forward) * Vector3.right * splitForce;
             go.transform.parent = transform.parent;
         }
         SoundTarget.Play("explosion" + Random.Range(1, 4));
         Destroy(this.gameObject);
     }
     else
     {
         if (!stayAlive)
         {
             SoundTarget.Play("explosion" + Random.Range(1, 4));
             Destroy(this.gameObject);
         }
     }
 }
示例#15
0
    // Update is called once per frame
    void Update()
    {
        Ocean ocean = Ocean.ocean;

        transform.position += transform.up * speed * Time.deltaTime;
        if (Vector3.Distance(ocean.transform.position, transform.position) > ocean.radius)
        {
            if (looped >= loops)
            {
                Destroy(this.gameObject);
            }
            else
            {
                Vector3 fromTo = ocean.transform.position - transform.position;
                transform.position += fromTo * 1.99f;
                looped++;
            }
        }
        for (int i = 0; i < Debris.all.Count; i++)
        {
            Debris deb = Debris.all[i];
            if (Vector3.Distance(transform.position, deb.transform.position) < deb.radius + radius)
            {
                if (!deb.CompareTag("plastic"))
                {
                    Score.record.Down();
                }
                deb.vel += transform.up * impactForce;
                Destroy(this.gameObject);
                deb.split = true;
            }
        }
    }
示例#16
0
        public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location)
        {
            FruitTreeSaveData fruitTreeSaveData = featureSaveData as FruitTreeSaveData;

            int numRemoved = 0;

            for (int i = 0; i < location.debris.Count; i++)
            {
                Debris debris = location.debris[i];

                if (debris.chunkType.Value == 382 && debris.Chunks.Count == 1 && debris.Chunks[0].debrisType == 382)
                {
                    if (!this.WithinRange(debris.Chunks[0].position.Value,
                                          GetCoalPosition(numRemoved, featureSaveData.FeaturePosition), Game1.tileSize * 2))
                    {
                        continue;
                    }

                    this.monitor.Log(
                        $"Removed dropped coal from fruit tree {numRemoved + 1}/{fruitTreeSaveData.FruitsOnTree}.",
                        LogLevel.Trace);
                    location.debris.RemoveAt(i);
                    i--;

                    numRemoved++;
                    if (numRemoved == fruitTreeSaveData.FruitsOnTree)
                    {
                        return;
                    }
                }
            }
        }
示例#17
0
文件: Debris.cs 项目: Cyberbanan/LD29
    public Debris Alloc()
    {
        Assert(IsPrefab);

        Debris result;

        if (next != null) {

            // RECYCLE INSTANCE
            result = next;
            next = result.next;
            result.next = null;
            result.gameObject.SetActive(true);

        } else {

            // CREATE NEW INSTANCE
            result = Dup(this);
            result.prefab = this;

        }

        // RE-INIT INSTANCE
        result.Init();
        return result;
    }
示例#18
0
        private void DropSparePartsToken()
        {
            Action Callback = Phases.CurrentSubPhase.CallBack;

            DecisionSubPhase.ConfirmDecisionNoCallback();

            HostUpgrade.State.SpendCharge();

            ManeuverTemplate dropTemplate = new ManeuverTemplate(ManeuverBearing.Straight, ManeuverDirection.Forward, ManeuverSpeed.Speed1, isBombTemplate: true);

            dropTemplate.ApplyTemplate(HostShip, HostShip.GetBack(), Direction.Bottom);

            Debris spareParts = new Debris("Spare Parts", "spareparts");

            spareParts.Spawn("Spare Parts " + HostShip.ShipId, Board.GetBoard());
            ObstaclesManager.AddObstacle(spareParts);

            spareParts.ObstacleGO.transform.position    = dropTemplate.GetFinalPosition();
            spareParts.ObstacleGO.transform.eulerAngles = dropTemplate.GetFinalAngles();
            spareParts.IsPlaced = true;

            GameManagerScript.Wait(
                1,
                delegate
            {
                Messages.ShowInfo("Spare Parts are dropped");
                dropTemplate.DestroyTemplate();
                BreakAllLocksRecursive(Callback);
            }
                );
        }
示例#19
0
        /// <summary>Prevents debris sinking if it contains or represents an item.</summary>
        /// <param name="debris">The sinking debris.</param>
        /// <param name="__instance">The <see cref="GameLocation"/> on which this method was called.</param>
        /// <param name="__result">The original method's return value. True if the debris should sink, false otherwise.</param>
        public static bool sinkDebris_Prefix(Debris debris, GameLocation __instance, ref bool __result)
        {
            try
            {
                if (debris != null)                                  //if the debris exists
                {
                    if (debris.IsAnItem())                           //if this debris represents an item
                    {
                        if (ModEntry.Config.TeleportItemsOutOfWater) //if this item should teleport out of water
                        {
                            TeleportDebrisOutOfWater(__instance, debris);
                        }

                        __result = false; //return false instead of the original result
                        return(false);    //skip the rest of the original method (note: this also skips any other patches on the method, depending on order)
                    }
                }

                return(true); //run the original method
            }
            catch (Exception ex)
            {
                ModEntry.Instance.Monitor.LogOnce($"Harmony patch \"{nameof(sinkDebris_Prefix)}\" has encountered an error:\n{ex.ToString()}", LogLevel.Error);
                return(true); //run the original method
            }
        }
示例#20
0
        private void DropSparePartsToken()
        {
            Action Callback = Phases.CurrentSubPhase.CallBack;

            DecisionSubPhase.ConfirmDecisionNoCallback();

            HostUpgrade.State.SpendCharge();

            Debris spareParts = new Debris("Spare Parts", "spareparts");

            spareParts.Spawn("Spare Parts " + HostShip.ShipId, Board.GetBoard());
            ObstaclesManager.AddObstacle(spareParts);

            spareParts.ObstacleGO.transform.position    = HostShip.GetBack();
            spareParts.ObstacleGO.transform.eulerAngles = HostShip.GetAngles() + new Vector3(0, 180, 0);
            spareParts.IsPlaced = true;

            GameManagerScript.Wait(
                1,
                delegate
            {
                Messages.ShowInfo("Spare Parts are dropped");
                BreakAllLocksRecursive(Callback);
            }
                );
        }
示例#21
0
        public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            base.DoFunction(location, x, y, power, who);
            who.Stamina = who.Stamina - ((float)(2 * power) - (float)who.ForagingLevel * 0.1f);
            int       tileX     = x / Game1.tileSize;
            int       tileY     = y / Game1.tileSize;
            Rectangle rectangle = new Rectangle(tileX * Game1.tileSize, tileY * Game1.tileSize, Game1.tileSize, Game1.tileSize);
            Vector2   index1    = new Vector2((float)tileX, (float)tileY);

            if (location.map.GetLayer("Buildings").Tiles[tileX, tileY] != null)
            {
                PropertyValue propertyValue = (PropertyValue)null;
                location.map.GetLayer("Buildings").Tiles[tileX, tileY].TileIndexProperties.TryGetValue("TreeStump", out propertyValue);
                if (propertyValue != null)
                {
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Axe.cs.14023"));
                    return;
                }
            }
            location.performToolAction((Tool)this, tileX, tileY);
            if (location.terrainFeatures.ContainsKey(index1) && location.terrainFeatures[index1].performToolAction((Tool)this, 0, index1, (GameLocation)null))
            {
                location.terrainFeatures.Remove(index1);
            }
            Rectangle boundingBox;

            if (location.largeTerrainFeatures != null)
            {
                for (int index2 = location.largeTerrainFeatures.Count - 1; index2 >= 0; --index2)
                {
                    boundingBox = location.largeTerrainFeatures[index2].getBoundingBox();
                    if (boundingBox.Intersects(rectangle) && location.largeTerrainFeatures[index2].performToolAction((Tool)this, 0, index1, (GameLocation)null))
                    {
                        location.largeTerrainFeatures.RemoveAt(index2);
                    }
                }
            }
            Vector2 index3 = new Vector2((float)tileX, (float)tileY);

            if (!location.Objects.ContainsKey(index3) || location.Objects[index3].Type == null || !location.Objects[index3].performToolAction((Tool)this))
            {
                return;
            }
            if (location.Objects[index3].type.Equals("Crafting") && location.Objects[index3].fragility != 2)
            {
                List <Debris> debris1      = location.debris;
                int           objectIndex  = location.Objects[index3].bigCraftable ? -location.Objects[index3].ParentSheetIndex : location.Objects[index3].ParentSheetIndex;
                Vector2       toolLocation = who.GetToolLocation(false);
                boundingBox = who.GetBoundingBox();
                double x1 = (double)boundingBox.Center.X;
                boundingBox = who.GetBoundingBox();
                double  y1             = (double)boundingBox.Center.Y;
                Vector2 playerPosition = new Vector2((float)x1, (float)y1);
                Debris  debris2        = new Debris(objectIndex, toolLocation, playerPosition);
                debris1.Add(debris2);
            }
            location.Objects[index3].performRemoveAction(index3, location);
            location.Objects.Remove(index3);
        }
示例#22
0
 void CreateDebris()
 {
     for (int i = 0; i < debrisMax; i++)
     {
         Debris zzz = Instantiate(debris, transform.position + new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(0, 0.5f), Random.Range(-0.5f, 0.5f)), transform.rotation);
         zzz.scale = Random.Range(0.1f, 4f);
     }
 }
示例#23
0
 public override Debris ModifyMonsterLoot(Debris debris)
 {
     if (debris != null)
     {
         debris.chunksMoveTowardPlayer = true;
     }
     return(debris);
 }
示例#24
0
 private void HandleDebris(Debris debris)
 {
     Utility.LookAt2d(transform, debris.transform.position);
     GetComponent <Rigidbody2D>().isKinematic = true;
     transform.SetParent(debris.transform);
     Destroy(GetComponent <Collider2D>());
     flashCoroutine = StartCoroutine(FlashAndExplode(3f));
 }
示例#25
0
        public override void Handle(BaseFeatureSaveData featureSaveData, GameLocation location)
        {
            int chunkType = -1;

            Debris.DebrisType debrisType = Debris.DebrisType.RESOURCE;
            int    numChunks             = -1;
            string removalMessage        = "";

            Random random = new Random((int)((double)Game1.uniqueIDForThisGame + (double)featureSaveData.featurePosition.X * 7.0 + (double)featureSaveData.featurePosition.Y * 11.0 + (double)Game1.mine.mineLevel + (double)Game1.player.timesReachedMineBottom));

            if (random.NextDouble() < 0.005)
            {
                chunkType      = 114;
                debrisType     = Debris.DebrisType.OBJECT;
                numChunks      = 1;
                removalMessage = "ancient seed";
            }
            else if (random.NextDouble() < 0.01)
            {
                bool lessThan = random.NextDouble() < 0.5;
                chunkType      = lessThan ? 382 : 8;
                debrisType     = lessThan ? Debris.DebrisType.RESOURCE : Debris.DebrisType.CHUNKS;
                numChunks      = random.Next(1, 2);
                removalMessage = "coal";
            }
            else if (random.NextDouble() < 0.02)
            {
                chunkType      = 92;
                debrisType     = Debris.DebrisType.OBJECT;
                numChunks      = random.Next(2, 4);
                removalMessage = "sap";
            }

            if (chunkType != -1)
            {
                //A bug in the game code adds items to Game1.currentLocation instead of the location of the CosmeticPlant.
                location = Game1.currentLocation;
                for (int i = 0; i < location.debris.Count; i++)
                {
                    Debris debris = location.debris[i];

                    if (debris.chunkType == chunkType && debris.debrisType == debrisType && debris.Chunks.Count == numChunks)
                    {
                        if (!WithinRange(featureSaveData.featurePosition, debris.Chunks[0].position / Game1.tileSize, 2))
                        {
                            continue;
                        }

                        location.debris.RemoveAt(i);
                        i--;

                        monitor.Log($"Removed {removalMessage} for grass.", LogLevel.Trace);

                        break;
                    }
                }
            }
        }
示例#26
0
文件: Player.cs 项目: Kuro-dake/DJam4
    private void LateUpdate()
    {
        Debris d = nearby_active_debris;

        if (d != null)
        {
            d.hilight = true;
        }
    }
示例#27
0
 void Start()
 {
     debrisScript            = debris.GetComponent <Debris>();
     rigidDebris             = debris.GetComponent <Rigidbody>();
     rootRender              = rootAssociated.GetComponent <Renderer>();
     rootInitMaterial        = rootRender.material;
     rootShader              = rootRender.material.shader;
     player.PlayerDeadEvent += TurnToNormality;
 }
示例#28
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Debris debris = col.gameObject.GetComponent <Debris>();

        if (debris != null)
        {
            shipBallController.spawnedBall.CollapseDebrisToBall(debris);
        }
    }
示例#29
0
 void Start()
 {
     debrisScript = debris.GetComponent<Debris>();
     rigidDebris = debris.GetComponent<Rigidbody>();
     rootRender = rootAssociated.GetComponent<Renderer>();
     rootInitMaterial = rootRender.material;
     rootShader = rootRender.material.shader;
     player.PlayerDeadEvent += TurnToNormality;
 }
示例#30
0
    void OnTriggerExit(Collider other)
    {
        Debris debris = other.transform.parent.GetComponent <Debris>();

        if (debris != null)
        {
            debrisInArea[debris.GetDebrisIndex()] = false;
        }
    }
示例#31
0
    public void AddToInventory(GameObject debris)
    {
        DebrisStructure debrisStructure = new DebrisStructure();
        Debris          debnfo          = debris.GetComponent <Debris>();

        debrisStructure.score  = debnfo.pointvalue;
        debrisStructure.sprite = debnfo.GetComponent <SpriteRenderer>().sprite;
        inventorylist.Add(debrisStructure);
    }
示例#32
0
    public virtual GameObject RipElectron()
    {
        GameObject p   = UnityEngine.Object.Instantiate(this.pElectron, this.transform.position, this.transform.rotation);
        Debris     deb = (Debris)p.GetComponent(typeof(Debris));

        deb.SetSpeed(3);
        deb.timeout = 4;
        this.e--;
        return(p);
    }
示例#33
0
文件: Debris.cs 项目: Cyberbanan/LD29
    public void Release()
    {
        if (prefab != null) {

            // DEACTIVATE AND PREPEND TO PREFAB'S FREELIST
            gameObject.SetActive(false);
            next = prefab.next;
            prefab.next = this;

        } else if (gameObject) {

            // THIS OBJECT WAS NOT DYNAMICALLY CREATED
            Destroy(gameObject);

        }
    }
示例#34
0
文件: SnakeBody.cs 项目: sinshu/dtf
 public void Destroy()
 {
     isDead = true;
     for (int i = 0; i < 2; i++)
     {
         int a = Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X) + Game.Random.Next(-60, 60 + 1);
         Bullet bullet = new SnakeBullet(Game, X, Y, Game.Random.Next(8, 12 + 1), a);
         Game.AddEnemyBullet(bullet);
     }
     int startAngle = Game.Random.Next(90);
     for (int i = 0; i < 8; i++)
     {
         int angle = startAngle + i * 45 + Game.Random.Next(-45, 46);
         double x = X + 16 * Utility.Cos(angle);
         double y = Y - 16 * Utility.Sin(angle);
         double speed = 0.5 + 1.5 * Game.Random.NextDouble();
         Effect debris = new Debris(Game, x, y, 128, 128, 128, speed, angle);
         Game.AddEffect(debris);
     }
     Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255);
     Game.AddEffect(effect);
     Game.PlaySound(Sound.Explosion);
 }
示例#35
0
文件: Borg.cs 项目: sinshu/dtf
 public override bool Hit()
 {
     if (hitPoints > 0)
     {
         hitPoints--;
         damaged = true;
         if (hitPoints > 0)
         {
             Game.PlaySound(Sound.EnemyDamage);
         }
     }
     if (hitPoints == 0)
     {
         int startAngle = Game.Random.Next(90);
         for (int i = 0; i < 12; i++)
         {
             int angle = startAngle + i * 45 + Game.Random.Next(-30, 31);
             double x = X + 24 * Utility.Cos(angle);
             double y = Y - 24 * Utility.Sin(angle);
             double speed = 0.5 + 1.5 * Game.Random.NextDouble();
             Effect debris = new Debris(Game, x, y, 255, 255, 255, speed, angle);
             Game.AddEffect(debris);
         }
         Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255);
         Game.AddEffect(effect);
         Game.PlaySound(Sound.Explosion);
         hitPoints--;
     }
     return true;
 }
示例#36
0
 public override bool Hit()
 {
     if (hitPoints > 0)
     {
         hitPoints--;
         if (hitPoints > 0)
         {
             Game.PlaySound(Sound.EnemyDamage);
         }
     }
     if (hitPoints == 0)
     {
         for (int i = 0; i < message.Length; i++)
         {
             for (int j = 0; j < message[i].Length; j++)
             {
                 double targetX = X - message[i].Length * 8 + j * 16 + 8;
                 double targetY = Y - message.Length * 8 + i * 16 + 8;
                 Effect effect = new SmallExplosionEffect(Game, targetX, targetY, Game.Random.Next(0, 360));
                 Effect debris1 = new Debris(Game, targetX, targetY, 255, 255, 255, Game.Random.Next(1, 5), Game.Random.Next(0, 360));
                 Effect debris2 = new Debris(Game, targetX, targetY, 255, 255, 255, Game.Random.Next(1, 5), Game.Random.Next(0, 360));
                 Game.AddEffect(effect);
                 Game.AddEffect(debris1);
                 Game.AddEffect(debris2);
             }
         }
         Game.PlaySound(Sound.Explosion);
         hitPoints--;
     }
     return true;
 }
示例#37
0
文件: RedEnemy.cs 项目: sinshu/dtf
 public override bool Hit()
 {
     isDead = true;
     int startAngle = Game.Random.Next(90);
     for (int i = 0; i < 8; i++)
     {
         int angle = startAngle + i * 45 + Game.Random.Next(-45, 46);
         double x = X + 16 * Utility.Cos(angle);
         double y = Y - 16 * Utility.Sin(angle);
         double speed = 0.5 + 1.5 * Game.Random.NextDouble();
         Effect debris = new Debris(Game, x, y, 255, 0, 0, speed, angle);
         Game.AddEffect(debris);
     }
     Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 192, 192);
     Game.AddEffect(effect);
     Game.PlaySound(Sound.Explosion);
     return true;
 }
示例#38
0
文件: Clipper.cs 项目: sinshu/dtf
 public override bool Hit()
 {
     if (hitPoints > 0)
     {
         hitPoints--;
         damaged = true;
         if (hitPoints > 0)
         {
             Game.PlaySound(Sound.EnemyDamage);
         }
     }
     if (hitPoints == 0)
     {
         isDead = true;
         foreach (Funnel funnel in funnels)
         {
             /*
             int startAngle = Game.Random.Next(90);
             for (int i = 0; i < 8; i++)
             {
                 int angle = startAngle + i * 45 + Game.Random.Next(-45, 46);
                 double x = funnel.X + 16 * Utility.Cos(angle);
                 double y = funnel.Y - 16 * Utility.Sin(angle);
                 double speed = 0.5 + 1.5 * Game.Random.NextDouble();
                 Effect debris = new Debris(Game, x, y, 255, 128, 0, speed, angle);
                 Game.AddEffect(debris);
             }
             */
             Effect effect = new BigExplosionEffect(Game, funnel.X, funnel.Y, Game.Random.Next(360), 255, 224, 192);
             Game.AddEffect(effect);
         }
         {
             int startAngle = Game.Random.Next(90);
             for (int i = 0; i < 8; i++)
             {
                 int angle = startAngle + i * 45 + Game.Random.Next(-45, 46);
                 double x = X + 16 * Utility.Cos(angle);
                 double y = Y - 16 * Utility.Sin(angle);
                 double speed = 0.5 + 1.5 * Game.Random.NextDouble();
                 Effect debris = new Debris(Game, x, y, 0, 0, 255, speed, angle);
                 Game.AddEffect(debris);
             }
             Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 192, 192, 255);
             Game.AddEffect(effect);
             Game.PlaySound(Sound.Explosion);
         }
         hitPoints--;
     }
     return true;
 }
示例#39
0
文件: FirstBoss.cs 项目: sinshu/dtf
        public override void Update()
        {
            damaged = false;

            if (isDying)
            {
                if (dyingCount < 30)
                {
                    if (dyingCount % 2 == 0)
                    {
                        Effect effect = new SmallExplosionEffect(Game, X + Game.Random.Next(-64, 64 + 1), Y + Game.Random.Next(-32, 32 + -+1), Game.Random.Next(0, 360));
                        Game.AddEffect(effect);
                        if (dyingCount % 4 == 0)
                        {
                            Game.PlaySound(Sound.Explosion);
                        }
                    }
                    dyingCount++;
                    if (dyingCount == 30)
                    {
                        int startAngle = Game.Random.Next(90);
                        for (int i = 0; i < 20; i++)
                        {
                            int angle = startAngle + i * 18 + Game.Random.Next(-18, 19);
                            double x = X + 64 * Utility.Cos(angle);
                            double y = Y - 32 * Utility.Sin(angle);
                            double speed = 0.5 + 1.5 * Game.Random.NextDouble();
                            Effect debris = new Debris(Game, x, y, 80, 80, 80, speed, angle);
                            Game.AddEffect(debris);
                        }
                        for (int i = -1; i <= 1; i++)
                        {
                            Effect effect = new BigExplosionEffect(Game, X - i * 48, Y, Game.Random.Next(0, 360), 255, 255, 255);
                            Game.AddEffect(effect);
                        }
                        Game.PlaySound(Sound.Explosion);
                    }
                }
                return;
            }

            if (moveCount > 0)
            {
                moveCount--;
                if (attackMode == 0)
                {
                    if (!(Math.Abs(X - targetX) < 32 && Math.Abs(Y - targetY) < 32))
                    {
                        Effect smoke1 = new Smoke(Game, X - 24, Y - 24, Game.Random.Next(0, 360));
                        Effect smoke2 = new Smoke(Game, X + 24, Y - 24, Game.Random.Next(0, 360));
                        Game.AddEffect(smoke1);
                        Game.AddEffect(smoke2);
                    }
                }
                if (!Game.Player.IsDead)
                {
                    if (attackMode == 1)
                    {
                        if (moveCount == 4)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                        else if (moveCount == 8)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                    }
                    else if (attackMode == 2)
                    {
                        if (moveCount == 4)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                        else if (moveCount == 8)
                        {
                            Bullet bullet1 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255);
                            Bullet bullet2 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270);
                            Bullet bullet3 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285);
                            Game.AddEnemyBullet(bullet1);
                            Game.AddEnemyBullet(bullet2);
                            Game.AddEnemyBullet(bullet3);
                            Game.PlaySound(Sound.OrangeFire);
                        }
                    }
                    else if (attackMode == 3)
                    {
                        if (moveCount == 12)
                        {
                            Bullet missile = new Missile(Game, X, Y + 16 - 32 * Utility.Sin(255), 270);
                            Game.AddEnemyBullet(missile);
                            Game.PlaySound(Sound.MissileFire);
                        }
                    }
                }
            }
            else
            {
                if (attackMode > 0)
                {
                    attackMode = Game.Random.Next(0, 4);
                }
                else
                {
                    attackMode = Game.Random.Next(1, 4);
                }
                targetX = (int)Math.Round(Game.Player.X) + Game.Random.Next(-32, 32 + 1);
                if (attackMode == 0)
                {
                    targetY = Game.FieldHeight - 32;
                }
                else
                {
                    targetY = Game.FieldHeight / 4 + Game.Random.Next(-32, 64 + 1);
                }
                if (hitPoints > 48)
                {
                    moveCount = Game.Random.Next(30, 60);
                }
                else if (hitPoints > 24)
                {
                    moveCount = Game.Random.Next(25, 50);
                }
                else
                {
                    moveCount = Game.Random.Next(20, 40);
                }
                if (targetX < 80)
                {
                    targetX = 80;
                }
                else if (targetX > Game.FieldWidth - 80)
                {
                    targetX = Game.FieldWidth - 80;
                }
            }
            x2 = targetX * 0.125 + x2 * 0.875;
            y2 = targetY * 0.125 + y2 * 0.875;
            X = x2 * 0.125 + X * 0.875;
            Y = y2 * 0.125 + Y * 0.875;
        }
示例#40
0
文件: Snake.cs 项目: sinshu/dtf
        public override void Update()
        {
            damaged = false;

            if (isDying)
            {
                if (dyingCount < POS_BUF_LEN_SUM)
                {
                    if (dyingCount % POS_BUF_LEN == 0)
                    {
                        bodies[dyingCount / POS_BUF_LEN].Destroy();
                    }
                    dyingCount++;
                }
                if (dyingCount == POS_BUF_LEN_SUM)
                {
                    int startAngle = Game.Random.Next(90);
                    for (int i = 0; i < 12; i++)
                    {
                        int angle = startAngle + i * 30 + Game.Random.Next(-30, 31);
                        double x = X + 32 * Utility.Cos(angle);
                        double y = Y - 32 * Utility.Sin(angle);
                        double speed = 0.5 + 1.5 * Game.Random.NextDouble();
                        Effect debris = new Debris(Game, x, y, 128, 128, 128, speed, angle);
                        Game.AddEffect(debris);
                    }
                    Effect effect1 = new BigExplosionEffect(Game, X + 16, Y, Game.Random.Next(360), 255, 255, 255);
                    Effect effect2 = new BigExplosionEffect(Game, X, Y - 16, Game.Random.Next(360), 255, 255, 255);
                    Effect effect3 = new BigExplosionEffect(Game, X - 16, Y, Game.Random.Next(360), 255, 255, 255);
                    Effect effect4 = new BigExplosionEffect(Game, X, Y + 16, Game.Random.Next(360), 255, 255, 255);
                    Game.AddEffect(effect1);
                    Game.AddEffect(effect2);
                    Game.AddEffect(effect3);
                    Game.AddEffect(effect4);
                    Game.PlaySound(Sound.Explosion);
                }
                return;
            }

            px = X;
            py = Y;
            for (int i = 0; i < POS_BUF_LEN_SUM - 1; i++)
            {
                posBufX[i] = posBufX[i + 1];
                posBufY[i] = posBufY[i + 1];
                angleBuf[i] = angleBuf[i + 1];
            }
            posBufX[POS_BUF_LEN_SUM - 1] = X;
            posBufY[POS_BUF_LEN_SUM - 1] = Y;
            angleBuf[POS_BUF_LEN_SUM - 1] = this.angle;

            if (Game.Ticks % 30 == 0)
            {
                if (Game.Random.Next(0, 8) != 0)
                {
                    targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1);
                    targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 192 + 1);
                }
                else
                {
                    targetX = (int)Math.Round(Game.Player.X);
                    targetY = (int)Math.Round(Game.Player.Y);
                }
            }
            if (Math.Abs(targetX - X) < 32 && Math.Abs(targetY - Y) < 32)
            {
                targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1);
                targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 192 + 1);
            }

            if (X < targetX)
            {
                vx += 1;
            }
            else if (targetX < X)
            {
                vx -= 1;
            }
            if (Math.Abs(vx) > MAX_SPEED)
            {
                vx = Math.Sign(vx) * MAX_SPEED;
            }
            if (Y < targetY)
            {
                vy += 1;
            }
            else if (targetY < Y)
            {
                vy -= 1;
            }
            if (Math.Abs(vy) > MAX_SPEED)
            {
                vy = Math.Sign(vy) * MAX_SPEED;
            }
            X += vx;
            Y += vy;

            for (int i = 0; i < NUM_BODIES; i++)
            {
                int index = POS_BUF_LEN * i;
                bodies[i].X = posBufX[index];
                bodies[i].Y = posBufY[index];
                bodies[i].Angle = angleBuf[index];
            }

            {
                int deg = Utility.NormalizeDeg(Utility.Atan2(py - Y, X - px) - angle);
                if (deg == -180)
                {
                    angle += Game.Random.Next(2) == 0 ? 1 : -1;
                }
                else if (Math.Abs(deg) < 16)
                {
                    angle = Utility.Atan2(py - Y, X - px);
                }
                else
                {
                    if (deg < 0)
                    {
                        angle -= 16;
                    }
                    else if (deg > 0)
                    {
                        angle += 16;
                    }
                }
            }

            if (attackCount > 0)
            {
                attackCount--;
                if (!Game.Player.IsDead)
                {
                    if (attackCount / 2 < NUM_BODIES)
                    {
                        if (attackCount % 2 == 0)
                        {
                            SnakeBody body = bodies[attackCount / 2];
                            int a = Utility.Atan2(body.Y - Game.Player.Y, Game.Player.X - body.X) + Game.Random.Next(-45, 45 + 1);
                            Bullet bullet = new SnakeBullet(Game, body.X, body.Y, Game.Random.Next(4, 8 + 1), a);
                            Game.AddEnemyBullet(bullet);
                        }
                    }
                }
            }
            else
            {
                attackCount = Game.Random.Next(60, 90);
            }
        }
示例#41
0
文件: Teki.cs 项目: sinshu/dtf
 public override bool Hit()
 {
     if (hitPoints > 0)
     {
         hitPoints--;
         if (hitPoints > 0)
         {
             Game.PlaySound(Sound.EnemyDamage);
         }
     }
     if (hitPoints == 0)
     {
         int startAngle = Game.Random.Next(90);
         for (int i = 0; i < 8; i++)
         {
             int angle = startAngle + i * 45 + Game.Random.Next(-45, 46);
             double x = X + 16 * Utility.Cos(angle);
             double y = Y - 16 * Utility.Sin(angle);
             double speed = 0.5 + 1.5 * Game.Random.NextDouble();
             Effect debris = new Debris(Game, x, y, type == 0 ? 255 : 0, type == 1 ? 255 : 0, type == 2 ? 255 : 0, speed, angle);
             Game.AddEffect(debris);
         }
         Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), type == 0 ? 255 : 192, type == 1 ? 255 : 192, type == 2 ? 255 : 192);
         Game.AddEffect(effect);
         Game.PlaySound(Sound.Explosion);
         hitPoints--;
     }
     return true;
 }