public void ToggleAttachmentOnSelectedKoboto(EAttachmentType attachmentType) { if (selectedKoboto != null) { selectedKoboto.ToggleAttachment(attachmentType); } }
public T GetAttachment <T>(EAttachmentType type) where T : AttachmentBase { if (currentAttachments.ContainsKey(type)) { return((T)currentAttachments[type]); } return(null); }
public void ToggleAttachment(EAttachmentType type) { Debug.Log("Toggle attachment " + type); if (currentAttachments.ContainsKey(type)) { RemoveAttachmentOfType(type); } else { AddAttachment(type); } }
public void RemoveAttachmentOfType(EAttachmentType type) { AttachmentBase attachment = null; if (currentAttachments.TryGetValue(type, out attachment)) { attachment.Remove(); EAttachmentTarget target = Attachments.AttachmentTarget(type); currentAttachments.Remove(type); attachmentTargetContents.Remove(target); SetupCollider(); } }
public void RemoveAttachmentFromTarget(EAttachmentTarget target) { AttachmentBase attachment = null; if (attachmentTargetContents.TryGetValue(target, out attachment)) { attachment.OnRemoveFromKoboto(this); attachment.Remove(); EAttachmentType type = attachment.attachmentType; currentAttachments.Remove(type); attachmentTargetContents.Remove(target); SetupCollider(); Debug.Log("Removeing attachment: " + type + " from " + target); } }
public async Task <ObjectId> UpdateAttachment( ObjectId categoryId, Stream fileStream, string fileName, EAttachmentType attachmentType) { var oldAttachmentId = await GetPropertyAsync(categoryId, x => x.Attachment); if (oldAttachmentId != default) { await _fileService.RemoveAsync(oldAttachmentId); } var newAttachmentId = await _fileService.CreateAsync(fileStream, fileName); await UpdatePropertyAsync(categoryId, x => x.Attachment, newAttachmentId); await UpdatePropertyAsync(categoryId, x => x.AttachmentType, attachmentType); return(newAttachmentId); }
public void AddAttachment(EAttachmentType type) { AttachmentBase attachment = Attachments.CreateNewAttachment(type); EAttachmentTarget target = Attachments.AttachmentTarget(type); RemoveAttachmentFromTarget(target); Transform attachToTransform = GetAttachmentTargetTransform(target); attachment.transform.SetParent(attachToTransform, false); attachmentTargetContents[target] = attachment; currentAttachments[attachment.attachmentType] = attachment; Debug.Log("Adding attachment: " + type + " to " + target); SetupCollider(); attachment.OnAttachToKoboto(this); }
public static AttachmentBase CreateNewAttachment(EAttachmentType type) { if (templates == null) { templates = new Dictionary <EAttachmentType, GameObject>(); } GameObject template = null; if (!templates.TryGetValue(type, out template)) { template = Resources.Load <GameObject>("Prefabs/Attachments/" + type.ToString()); templates[type] = template; } var attachmentObj = GameObject.Instantiate(template); return(attachmentObj.GetComponent <AttachmentBase>()); }
public static EAttachmentTarget AttachmentTarget(EAttachmentType type) { switch (type) { case EAttachmentType.Wheels: case EAttachmentType.DoubleWheels: return(EAttachmentTarget.Wheels); case EAttachmentType.Spring: return(EAttachmentTarget.Bottom); case EAttachmentType.Hammer: return(EAttachmentTarget.Front); case EAttachmentType.Jetpack: return(EAttachmentTarget.Jetpack); } return(EAttachmentTarget.Top); }
public void AttachmentButtonPressed(EAttachmentType type) { currentLevel.ToggleAttachmentOnSelectedKoboto(type); }
public void AttachmentButtonPressed(UIAttachmentButton button, EAttachmentType type) { game.AttachmentButtonPressed(type); }