예제 #1
0
        public void Update()
        {
            timeSinceLastMove++;
            if (timeSinceLastMove < delayUntilNextMove)
            {
                return;
            }

            var container = parent.GetComponent <Container>();

            if (container == null || container.Ressource == null || container.Ressource.Quantity == 0)
            {
                return;
            }

            var cellTarget = target.GetNeighboor(parent.Position);

            if (cellTarget.FactoryEntity == null)
            {
                return;
            }

            var containerTarget = cellTarget.FactoryEntity.GetComponent <Container>();

            timeSinceLastMove = 0;
            alreadyReset      = false;

            if (containerTarget != null)
            {
                containerTarget.Receive(container.Ressource);
                container.Gather(container.Ressource);
            }
        }
예제 #2
0
        public void Update()
        {
            timeSinceLastProduction++;
            if (timeSinceLastProduction < timeToProduce)
            {
                return;
            }

            timeSinceLastProduction = 0;
            if (ressource == null)
            {
                return;
            }

            if (container == null)
            {
                container = parent.GetComponent <Container>();
            }

            container.Receive(ressource);
        }
예제 #3
0
        public void Update()
        {
            if (container == null)
            {
                container = parent.GetComponent <Container>();
            }

            timeSinceLastProduction++;
            if (timeSinceLastProduction < timeToProduce)
            {
                return;
            }

            if (container.Ressource != null && container.Ressource.Quantity > 0)
            {
                container.Ressource.Quantity = 0;
                timeSinceLastProduction      = 0;
                Mecha mecha = new Mecha(
                    "MK" + productionNumber, parent.Position, parent.Owner);
                parent.Owner.AddUnit(mecha);
                productionNumber++;
            }
        }
예제 #4
0
        public static List <string> GetDetails(FactoryEntity component)
        {
            var details = new List <string>();

            details.Add(component.Position.ToString());
            details.Add(component.Name);
            details.Add("Owner: " + component.Owner.Name);
            if (component.GetComponent <Generator>() != null)
            {
                var generator = component.GetComponent <Generator>();
                details.Add("--- Generator");
                details.Add("Harvest: " + generator.Ressource.Name);
                if (component.GetComponent <Container>() != null)
                {
                    var container = component.GetComponent <Container>();
                    details.Add("--- Container");
                    if (container.Ressource != null)
                    {
                        details.Add("Amount: " + container.Ressource.Quantity);
                    }
                }
            }
            else if (component.GetComponent <Container>() != null)
            {
                var container = component.GetComponent <Container>();
                details.Add("--- Container");
                if (container.Ressource != null)
                {
                    details.Add("Hold: " + container.Ressource.Name);
                    details.Add("Amount: " + container.Ressource.Quantity);
                }
                else
                {
                    details.Add("Hold: Nothing");
                }
            }
            if (component.GetComponent <Grabber>() != null)
            {
                details.Add("--- Grabber");
                var grabber = component.GetComponent <Grabber>();
                details.Add("Move: " + grabber.Ressource.Name);
                details.Add("By: " + grabber.Ressource.Quantity + "/tick");
                details.Add("IN: " + Enum.GetName(typeof(Orientation), grabber.Input));
                details.Add("OUT: " + Enum.GetName(typeof(Orientation), grabber.Output));
            }
            if (component.GetComponent <PutInto>() != null)
            {
                details.Add("--- PutInto");
                var putInto = component.GetComponent <PutInto>();
                if (putInto.Ressource != null)
                {
                    details.Add("Move: " + putInto.Ressource.Name);
                }
                else
                {
                    details.Add("Move: Nothing");
                }
                details.Add("To: " + putInto.Target);
            }
            if (component.GetComponent <Destructible>() != null)
            {
                details.Add("--- Destructible");
                var destructible = component.GetComponent <Destructible>();
                details.Add("Health: " + destructible.CurrentHealth + "/" + destructible.MaxHealth);
            }
//			if(component.GetType() == typeof(Harvester)) {
//				details.Add(component.Position.ToString());
//				details.Add(component.Name);
//				details.Add("Owner: " + component.Owner.Name);
//				details.Add("Gather: " + (component as Harvester).Ressource.Name);
//			} else if(component.GetType() == typeof(Conveyor)) {
//				details.Add(component.Position.ToString());
//				details.Add(component.Name);
//				details.Add("Owner: " + component.Owner.Name);
//				if((component as Conveyor).Ressource != null) {
//					details.Add("Carry: " + (component as Conveyor).Ressource.Name);
//				}
//				else
//					details.Add("Carry: Nothing");
//				details.Add("Feeding " + Enum.GetName(typeof(Orientation), (component as Conveyor).Orientation));
//			} else if(component.GetType() == typeof(Builder)) {
//				details.Add(component.Position.ToString());
//				details.Add(component.Name);
//				details.Add("Owner: " + component.Owner.Name);
//				if((component as Builder).Ressource != null) {
//					details.Add("Hold: " + (component as Builder).Ressource.Name);
//				}
//				else
//					details.Add("Hold: Empty");
//			}

            return(details);
        }